Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在Windows phone 8中访问web服务_C#_Asp.net Mvc_Windows Phone 8_Windows Phone 8.1 - Fatal编程技术网

C# 在Windows phone 8中访问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

我正在尝试访问Windows phone中的web服务。但我找不到任何特定的方法来访问此web服务。我只是在下面创建web服务方法

 [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;
}