问题描述
大家好,
我通过使用Windows Azure云服务开发了wcf服务.
现在,我需要将该wcf服务调用到我的应用程序中.我正在使用Rad Center Windows Phone应用程序.我在服务参考中添加了wcf服务,但无法创建
page1.xaml.cs 中的参考.任何建议表示赞赏.
注意:我已经浏览了下面的链接,但对我的概念没有帮助.
在此先感谢.
nareshraju
Hi all,
I developed a wcf service by using windows Azure Cloud service.
Now i need to call that wcf service into my application. I am using Rad center windows phone application. I added wcf service in service reference but not possible to create
a reference in page1.xaml.cs . any suggestions appreciate.
Note: I already goggled i got below link but not useful to my concept.
thanks in advance.
nareshraju
推荐答案
public Page1()
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(Page1_Loaded);
}
void Page1_Loaded(object sender, RoutedEventArgs e)
{
// Instantiate a web service client
// Note that the name MyWebService gets the word Client appended
MyServiceReference.MyWebServiceClient proxy = new MyServiceReference.MyWebServiceClient();
// Create a handler for the webservice - note it has the word Completed on the end of the web service operation included
proxy.Get42Completed += new
EventHandler<MyServiceReference.Get42CompletedEventArgs>
(GetDataCompleted);
// Make the call to the webservice, note it has the word Async appended
proxy.Get42Async();
}
void Get42Completed(object sender,
MyServiceReference.Get42CompletedEventArgs e)
{
// Always check for errors before examining the result
if(e.Error != null)
{
MessageBox.Show(e.Error.ToString());
return;
}
// Read the result
MessageBox.Show(e.Result.ToString());
}
以下是需要注意的几件事...
您的服务参考应设置为允许异步调用,因此请右键单击它,然后选择配置服务参考"并进行检查.还要检查您的Web服务没有将其操作标记为静态,因为这会使它们对客户端不可见.
希望有帮助.
如果这能回答您的问题,请标记为答案.
Here are a few things to watch out for...
Your service reference should be set to allow Async calls, so right click it, and choose "Configure service reference" and check that. Also check that your web service hasn''t got its operations marked as static as that makes them invisible to the client.
Hope that helps.
Please mark as the answer if this answers your question.
这篇关于如何在Rad Center Windows Phone应用程序中调用WCF服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!