C# 在Windows phone 8中访问web服务
我正在尝试访问Windows phone中的web服务。但我找不到任何特定的方法来访问此web服务。我只是在下面创建web服务方法C# 在Windows phone 8中访问web服务,c#,asp.net-mvc,windows-phone-8,windows-phone-8.1,C#,Asp.net Mvc,Windows Phone 8,Windows Phone 8.1,我正在尝试访问Windows phone中的web服务。但我找不到任何特定的方法来访问此web服务。我只是在下面创建web服务方法 [WebMethod] public string ListCategory(int Id, string JsonXml) { tidybeans.DAL.Category category = new tidybeans.DAL.Category(); if (JsonXml.To
[WebMethod]
public string ListCategory(int Id, string JsonXml)
{
tidybeans.DAL.Category category = new tidybeans.DAL.Category();
if (JsonXml.ToLower() == ("Json").ToLower())
return CreateJsonParameters(category.GetAllDS(Id));
else if (JsonXml.ToLower() == ("xml").ToLower())
return ConvertDatatableToXML(category.GetAllDS(Id));
else
return "Please enter the type";
}
现在,我无法在Windows phone 8应用程序中找到任何使用web服务的方法。将web服务作为服务引用添加到项目中。实例化其soap客户端并使用它调用web服务方法 Windows phone使用异步操作 例如:
ExampleService.MyWebServiceSoapClient client = new ExampleService.MyWebServiceSoapClient();
(用你的方法)
(listcategorycompleted方法)
ExampleService是服务引用的名称我得到了抛出的“System.Net.WebException”类型的异常。Thnks Nyandika。使用错误的方法显示是我的错误
client.ListCategoryCompleted += client_ListCategoryCompleted;
client.ListCategoryAsync(Id,JsonXml);
void client_ListCategoryCompleted(object sender, ExampleService.ListCategoryCompletedEventArgs e)
{
//you can hanlde the result here
//txtDisplay.Text = e.Result;
}