如何在Windows Phone 7中调用webservice方法?

Sra*_*nti 3 windows-phone-7

为了连接到webservices,我编写了以下代码.

WebClient wc = new WebClient();
wc.DownloadStringAsync(new Uri("http://www.Webservices.asmx"));
wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);

void wc_DownloadStringCompleted(object sender,DownloadStringCompletedEventArgs e)
{
    Debug.WriteLine("Web service says: " + e.Result);
    using (var reader = new StringReader(e.Result))
    {
        String str = reader.ReadToEnd();
    }
}
Run Code Online (Sandbox Code Playgroud)

通过使用上面的代码获取字符串结果.但我想在HTMLVisulaizer中获得结果然后我知道有什么方法有webservice.then我可以轻松访问特定的方法.请告诉我如何在Windows Phone 7中调用Web服务方法?在webservice中我有5个webmethods.how来获取它以及如何调用特殊webmenthod.

请提前告诉我.

Jas*_*mes 5

@venkateswara您是在谈论获取已知WebReference方法的列表,以便您知道在代码中调用哪一个?将WebReference添加到WP7项目时,是否看不到已知方法调用?由于你将在VS中开发WP7应用程序,我看不出你想要这样做的原因.即使您自己不拥有Web服务,也需要从VS连接到它以添加对项目的引用.

下面是VS2010中添加了WebReference的屏幕.在操作上列出的权利.

在此输入图像描述

添加后,您可以使用ObjectBrowser来了解如何调用这些方法.

如果我错过了你的问题,请告诉我.