[英]Calling asmx service method using HttpClient
I want call asmx web service method to use HttpClient
and i have tried with this code but it returned 404 status code.How can i call asmx service using HttpClient
. 我想调用asmx Web服务方法以使用
HttpClient
并且我尝试使用此代码,但返回了404状态代码。如何使用HttpClient
调用asmx服务。
HttpClient client = new HttpClient();
client.BaseAddress=new Uri(@"http://../vbtTest/WS/BimserStratejikPlanService.asmx");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
HttpResponseMessage response = client.GetAsync("AktarimListesi").Result;
if (response.IsSuccessStatusCode)
{
}
The HTTP 404
error means that the server could not find the requested resource. HTTP
404
错误表示服务器找不到请求的资源。
This is possibly down to a incorrect URL or you are using an incorrect HTTP Verb (GET) as suggested by Panagiotis Kanavos. 这可能归因于错误的URL,或者您使用的是Panagiotis Kanavos建议的不正确的HTTP Verb(GET)。
This URL " http://../vbtTest/WS/BimserStratejikPlanService.asmx " - I'm presuming you're trying to execute this from within an ASPX page. 该URL“ http://../vbtTest/WS/BimserStratejikPlanService.asmx ”-我假设您正在尝试从ASPX页面内执行此操作。 ".." as a prefix will not work.
“ ..”作为前缀将不起作用。 You need to provide an absolute URL.
您需要提供一个绝对URL。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.