我服务端有个WCF服务,这个服务对于在android、IOS,ASP.NET的POSt请求都能正常接收和返回,本人刚接触WP7不久,项目也是使用POST请求WCF,请求部署在本地WCF服务能正常工作,但是请求服务器上的就会出现:“The remote server returned an error:NOtFound”异常,请求代码如下:
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://61.145.163.72:8089/WCFService/Service.svc/Login");
myRequest.Method =
"POST"
;
myRequest.ContentType =
"application/json"
;
myRequest.BeginGetRequestStream(
new
AsyncCallback(GetRequestStreamCallback), myRequest);
private
void
GetRequestStreamCallback(IAsyncResult asynchronousResult)
{
HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;
System.IO.Stream postStream = request.EndGetRequestStream(asynchronousResult);
string
parametersString =
"username=admin&password=123456"
;
byte
[] byteArray = System.Text.Encoding.UTF8.GetBytes(parametersString);
postStream.Write(byteArray, 0, parametersString.Length);
postStream.Close();
request.BeginGetResponse(
new
AsyncCallback(GetResponseCallback), request);
}
private
void
GetResponseCallback(IAsyncResult asynchronousResult)
{
HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;
HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult);
Stream streamResponse = response.GetResponseStream();
StreamReader streamRead =
new
StreamReader(streamResponse);
string
responseString = streamRead.ReadToEnd();
streamResponse.Close();
streamRead.Close();
}
运行到
HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;
HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult);会抛出“The remote server returned an error:NotFound”异常
这个问题亟待解决,有哪位前辈和大哥知道告诉小弟,或者帮我提供一下其他WP7下POST请求WCF的方法也行,谢谢了
在服务器上一般比本地的要求严格一些,你好好检查一些哪儿可能发生的漏洞,或者逻辑不严密。都有可能导致你这个问题。
如何建一个WCF支持android的调用,且能宿主到IIS上,谁能给个完整的测试代码。谢谢啦!
REST WCF
你问题有什么好的解决方案吗?我也会遇到了类似的问题还没解决
我也遇到这个问题了~
请问你是怎么解决的?我做的WP8上传图片也遇到了这个问题,不知道是我的问题,还是服务器的问题,提前感谢。