我正在尝试创建一个从ASMX Webservice获取数据的Xamarin表单项目
这是我正在使用的代码
var httpClient = new HttpClient();
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
httpClient.DefaultRequestHeaders.Add("SOAPAction", "http://mobile.xn--schller-golf-xjb.dk/WebServices/IndoorServices.asmx/IndoorBruttoGns");
string soapstr = string.Format(@"<?xml version=""1.0"" encoding=""utf-8""?>
<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">
<soap:Body>
< IndoorBruttoGns xmlns = ""http://mobile.xn--schller-golf-xjb.dk/WebServices"" />
</soap:Body>
</soap:Envelope>");
var response = httpClient.PostAsync("http://mobile.xn--schller-golf-xjb.dk/WebServices/IndoorServices.asmx/IndoorBruttoGns", new StringContent(soapstr, Encoding.UTF8, "application/json")).Result;
var content = response.Content.ReadAsStringAsync().Result;
return content;
Web服务不需要任何输入,但我收到500内部服务器错误,我知道Web服务有效,因为我使用$ .ajax从PhoneGap项目调用它