StatusCode:404,ReasonPhrase:'Not Found',版本:1.1

时间:2017-10-04 11:13:38

标签: c# windows

我试图在Windows StoreApp Windows Phone 8.1中调用Web服务,但由于某些原因它返回一个空字符串,当我深入查看详细信息时,我得到类似“StatusCode:404,ReasonPhrase:'Not Found',Version :1.1“ 请参阅代码

private async Task<string> WCFRESTServiceCall(string methodRequestType, string methodName, string bodyParam = "")
    {
        string ServiceURI = "http://localhost:34826/WCFRestDemo.svc/rest/" + methodName;
        HttpClient httpClient = new HttpClient();
        HttpRequestMessage request = new HttpRequestMessage(methodRequestType == "GET" ? HttpMethod.Get : HttpMethod.Post, ServiceURI);
        if (!string.IsNullOrEmpty(bodyParam))
        {
            request.Content = new StringContent(bodyParam, Encoding.UTF8, "application/json"); 
        }
        HttpResponseMessage response = await httpClient.SendAsync(request);
        string returnString = await response.Content.ReadAsStringAsync();
        return returnString;
    }

我可以直接从浏览器访问webservice并使用相同的URL获取响应

0 个答案:

没有答案