Results 1 to 6 of 6

Thread: Windows phone 7:Web-request response?

  1. #1
    Join Date
    Sep 2010
    Posts
    65

    Windows phone 7:Web-request response?

    From a very long time I am using the windows 7 mobile phone, it working great with the features. I am basically using this one for the access the internet, the web service is excellent. But the problem is the web request response is using another thread to run it. I can’t get the response directly, so I would like to know is there any way to get the asynchronous web-request response? Any solution to access the main tread of the controller? Any idea on this issue?

  2. #2
    Join Date
    May 2008
    Posts
    2,464

    Re: Windows 7 phone:Web-request response?

    If the web address that you wants to access is authenticated with the internet? If not then authentication it with e web service that you are using in your windows mobile. By this you can later make a registration with the associate URI for the request back of the, after that you will got the request back of every response with the web service. After the registration if the device is found in the inactive mode them Microsoft will send the notification service on the make a response with the URI. And then when the device will return into the active mode then this will re-register the service with the desire URI. If it register multiple time with the subscription of the page then the call for the request is to be maintained with the subscription. During the registration with the web make sure that the page contains the information about the web service of the page from where you wish to get the response back of the request, and the device should be in the active mode. i did this in my windows mobile, it will works greatly, suggest you to go through this procedure it will definitely help you to get the response back of the request.
    Last edited by Mario2; 27-10-2010 at 06:06 PM.

  3. #3
    Join Date
    Apr 2008
    Posts
    3,424

    Re: Windows 7 phone:Web-request response?

    Code:
    // Create a web request to send the register callback request to the Push Notification Service.
    HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(mpnCallbackServiceUri);
    
    // A mandatory custom header that specifies the URI to post the callback message to when any registered event with the associated subscription triggers.
    webRequest.Headers.Add("X-CallbackURI", callbackUri);  
    
    // HTTP POST is the only allowed method to send the notification.
    webRequest.Method = "POST";
    
    // Sets the web request content length.
    webRequest.ContentLength = callbackMessage.Length;
    
    // Set the content type according to the type of callback message being sent. 
    webRequest.ContentType = "application/*";
    
    using (Stream requestStream = webRequest.GetRequestStream())
    {
        requestStream.Write(callbackMessage, 0, callbackMessage.Length);
    }
    
    // Get the response. This example gets the web response synchronously but a web service can get it asynchronously as well.
    HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
    
    // Ensure that the 'HTTP 200 OK' response is received from the Push Notification Service.
    Debug.Assert(response.StatusCode == HttpStatusCode.OK);

    The above script will help you to get the response of the access web service from your windows 7 phone.

  4. #4
    Join Date
    May 2008
    Posts
    3,516

    Re: Windows 7 phone:Web-request response?

    The WCF application will help to get the response of the requested web service in a synchronous manner. It is quite sticky but it will work straight forward in the window 7 phone, also it will works with the Silverlight application, the way it is working is the just simply copy and paste the file in the request page for the response. This one is works fine with the Silverlight compatible windows mobile phone. In the silverlight windows phone add this in the library of the project, by following the simple steps to install this one. After that reference the library with the main of the project and along with that add the handle for the return of the event as like you wish to get them. Now try to to send the request of the web service and wait for the response of the request from the web, but during sending the request remember that the WCF should know the operation otherwise it will not response.

  5. #5
    Join Date
    Apr 2008
    Posts
    3,339

    Re: Windows 7 phone:Web-request response?

    I read your post, and suggest you to first you go through the synchronous and then you go for the asynchronous response method. There is script that I used for the synchronous response in my windows Silverlight phone. Try with this one; it might be also works in the windows 7 phone. Here instead of calling the function I returned the value to the desired place of the web service. Then you make the call function to delegate the service and after that you call that function to invoke the operation.
    Code:
    void DoSomethingAsync( Action<string> callback ) {
        HttpWebRequest req; // TODO: build your request
    
        req.BeginGetResponse( result => {
            // This anonymous function is a closure and has access 
            // to the containing (or enclosing) function.
            var response = req.EndGetResponse( result );
    
            // Get the result string and call the callback
            string resultString = null; // TODO: read from the stream
    
            callback(resultString);
        }, null );
    }
    Script for call the function.

    Code:
    void btnGo_Click( object sender, EventArgs e ) {
        DoSomethingAsync( resultString => {
            // This anonymous function is called when the web request has
            // finished and has your string. 
    
            // Now that we have the string, we can go and process it.
            ProcessWebResponseResult( resultString );
        });
    }

  6. #6
    Join Date
    Jan 2006
    Posts
    4,221

    Re: Windows 7 phone:Web-request response?

    you need to make the function which will create the asynchronous call to the desired function of the web service. After the execution of the call back command the response will return automatically I think that. The return value or the response that you mentioned in your post will not comes in the asynchronous manner. If you wish to get it the response as the manner of asynchronous then you have to block the URI of the service, it will works as the waiting facility of the service. You should also pass the service patching code if you are using that one with your service for the web. By sending this it will call back the execute response. In the marshal of the service the request will placed in the text-box of the device, which is used for the modification of the priority of the event service. Re-fetch the URI data in the counter of the service, make sure that it will not transfer into the different category counter.

Similar Threads

  1. Replies: 4
    Last Post: 11-01-2014, 10:14 AM
  2. Replies: 6
    Last Post: 31-10-2011, 10:33 PM
  3. How does a servlet handles request and gives response ?
    By Lolita in forum Software Development
    Replies: 3
    Last Post: 05-02-2011, 09:28 AM
  4. Windows phone 7 breaks the HTTP request
    By Tajdar7 in forum Portable Devices
    Replies: 3
    Last Post: 27-10-2010, 06:50 AM
  5. Tod request sent - no response received
    By Raffaele in forum Networking & Security
    Replies: 3
    Last Post: 31-07-2009, 10:43 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,715,135,032.06021 seconds with 17 queries