When using HttpWebRequest on WP7, Request.EndGetResponse throwing "Not Found" error after 1 minute
I am using HttpWebRequest to call a webservice from WP7.
Everything works fine on WP7 emulator but when i use WP7 device, it throws "Not Found" exception if webservice doesn't respond in 1 minute.
i did not find any property to increase the timeout of HttpWebRequest in WP7 framework.
below is code i am using
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
var res = request.BeginGetRequestStream(
new AsyncCallback((streamResult) =>
{
byte[] requestBytes = Encoding.UTF8.GetBytes(soapRequestEnvelope);
try
{
using (Stream requestStream = request.EndGetRequestStream(streamResult))
{
requestStream.Write(requestBytes, 0, Encoding.UTF8.GetByteCount(soapRequestEnvelope));
}
}
catch (Exception e)
{
}
request.BeginGetResponse(new AsyncCallback((ar) =>
{
try
{
HttpWebRequest Request = (HttpWebRequest)ar.AsyncState;
if (Request != null)
{
//below line throws error if response doesn't come in 1 Minute
using (HttpWebResponse webResponse = (HttpWebResponse)Request.EndGetResponse(ar))
{
StreamReader reader = new StreamReader(webResponse.GetResponseStream());
开发者_开发技巧 //Response comes here
string text = reader.ReadToEnd();
}
}
}
catch (Exception ex)
{
}
}), request);
}), request);
Pleae help me out?
Thanks, SK
Be sure that you're not calling a local web service, your device is not able to resolve localhost instead of emulator
精彩评论