How to access a SOAP service from Windows Store App using WinJS.xhr? RRS feed

  • Question

  • I want to use the WinJS.xhr method to access a SOAP web service from my JS Windows Store App?

    Have tried the following code but it doesn't work. Please help.

    var options = {
        url: "http://www.webservicex.net/ConvertTemperature.asmx",
        data: '<?xml version="1.0" encoding="utf-8"?>' +
    '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="'">http://schemas.xmlsoap.org/soap/envelope/">' +
    '<soap:Body>' +
    '<m:ConvertTemp xmlns:m="'">http://www.webserviceX.NET">' +
    '<m:Temperature>37.4</m:Temperature>' +
    '<m:FromUnit>degreeCelsius</m:FromUnit>' +
    '<m:ToUnit>degreeFahrenheit</m:ToUnit>' +
    '</m:ConvertTemp>' +
    '</soap:Body>' +


        function (request) {
            var output = request.responseText;
            xhrDiv.innerHTML = window.toStaticHTML(output);


        function errorfunction(result) {
            xhrDiv.innerHTML = result;
            xhrDiv.style.backgroundColor = "#FF0000";

        function progress(result) {
            xhrDiv.innerText = "Ready state is " + result.readyState;
            xhrDiv.style.backgroundColor = "#0000FF";

    Saturday, May 4, 2013 6:14 PM


  • Hi RG2408,

    From the code you provided, I find that you hasn't specified the "type" for the WinJS.xhr request. For ASMX webservice via SOAP http endpoint, you need to send the request via HTTP POST request. If you hasn't explicitly specified request type, WinJS.xhr by default use HTTP GET.

    #WinJS.xhr function

    #Making HTTP Requests in Windows Store Apps

    Also, I suggest you first create a .NET console client to invoke the webservice and use fiddler to capture the HTTP requests so as to get what exactly does the correct request message/headers look like. You can also use fiddler to check the requests sent by your windows store app so as to compare it with the correct one to find out difference.

    #Fiddler web debugging proxy

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, May 6, 2013 1:38 AM