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
.
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.
This is possibly down to a incorrect URL or you are using an incorrect HTTP Verb (GET) as suggested by Panagiotis Kanavos.
This URL " http://../vbtTest/WS/BimserStratejikPlanService.asmx " - I'm presuming you're trying to execute this from within an ASPX page. ".." as a prefix will not work. You need to provide an absolute URL.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.