httpwebrequest BeginGetResponse 回调在 60 秒内触发 WP7

发布于 2024-12-03 14:26:40 字数 354 浏览 0 评论 0原文

我正在尝试使用网络服务将一些数据获取到 WP7 设备。

我正在使用 HttpWebRequest 对象从我的服务获取数据...在 WP7 模拟器上一切正常,但是当我尝试在 WP7 设备上运行应用程序时,BeginGetResponse 回调会在 1 分/60 秒后触发,响应状态为“未找到”。

但是,如果服务在 60 秒之前返回数据,那么它也可以在 WP7 设备上运行...

我已经使用示例方法创建了一个示例 Web 服务,该方法具有 Thread.Sleep 两分钟,它可以在 WP7 模拟器上运行,但不能在 WP7 设备上运行....

以前有人遇到过这样的问题吗???

请帮帮我。

谢谢, SK

I am trying to fetch some data to WP7 device using a websevice.

I am using HttpWebRequest object to get the data from my service... everything works well on WP7 Emulator, but when i try to run the application on WP7 device BeginGetResponse callback fires after 1 min/60 seconds with response status "Not Found".

But if service returns data before 60 seconds then it works on WP7 device as well....

i have crated a sample web service with a sample method which has Thread.Sleep for two minutes it works on WP7 Emulator but not working on WP7 device....

did anybody faces any issue like this before???

Please help me out.

Thanks,
SK

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

メ斷腸人バ 2024-12-10 14:26:40

我正在使用下面的代码来访问服务...相同的代码在 WP7 模拟器上工作,但在 WP7 设备上...

        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

        request.ContentType = contentType;
        request.Method = method;

        request.Headers["SOAPAction"] = @"http://tempuri.org/HelloWorldT";
        request.Headers["KeepAlive"] = "true";

        var res = request.BeginGetRequestStream(
           new AsyncCallback((streamResult) =>
           {
               soapRequestEnvelope = @"<s:Envelope xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'><s:Body><HelloWorldT xmlns='http://tempuri.org/' xmlns:a='http://schemas.datacontract.org/2004/07/WindowsFormsApplication1.ServiceReference1' xmlns:i='http://www.w3.org/2001/XMLSchema-instance'/></s:Body></s:Envelope>";
               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)
                       {

                           using (HttpWebResponse webResponse = (HttpWebResponse)Request.EndGetResponse(ar))
                           {
                               StreamReader reader = new StreamReader(webResponse.GetResponseStream());
                               string text = reader.ReadToEnd();
                           }
                       }
                   }
                   catch (Exception ex)
                   {
                   }

               }), request);


           }), request);

I am using below code to hit the service... same code is working on WP7 Emulator but on WP7 device...

        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

        request.ContentType = contentType;
        request.Method = method;

        request.Headers["SOAPAction"] = @"http://tempuri.org/HelloWorldT";
        request.Headers["KeepAlive"] = "true";

        var res = request.BeginGetRequestStream(
           new AsyncCallback((streamResult) =>
           {
               soapRequestEnvelope = @"<s:Envelope xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'><s:Body><HelloWorldT xmlns='http://tempuri.org/' xmlns:a='http://schemas.datacontract.org/2004/07/WindowsFormsApplication1.ServiceReference1' xmlns:i='http://www.w3.org/2001/XMLSchema-instance'/></s:Body></s:Envelope>";
               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)
                       {

                           using (HttpWebResponse webResponse = (HttpWebResponse)Request.EndGetResponse(ar))
                           {
                               StreamReader reader = new StreamReader(webResponse.GetResponseStream());
                               string text = reader.ReadToEnd();
                           }
                       }
                   }
                   catch (Exception ex)
                   {
                   }

               }), request);


           }), request);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文