You must Sign In to post a response.
  • Category: ASP.Net MVC

    How to access remote XML webservice in Jquery or webapi?

    Hi,
    I have a remote xml webservice like http://www.googleapi.com/webservice/rest/server.php?wsfunction=local_wsolpuserinfo which will return xml data.
    I am getting error as below

    XMLHttpRequest cannot load http://www.googleapi.com/webservice/rest/server.php?wsfunction=local_wsolpuserinfo . No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost is therefore not allowed access.

    I tried to use jsonp but its not working because returned data is xml.
    So how to avoid this cross origin error

    my code is below

    $.ajax({
    method: 'get',
    params: data,
    url: 'http://www.googleapi.com/webservice/rest/server.php?wsfunction=local_wsolpuserinfo',
    headers: {'X-Requested-With': 'XMLHttpRequest'},
    dataType: "text",
    beforeSend: function (xhr) {
    xhr.setRequestHeader('Access-Control-Allow-origin', 'true');

    },
    contentType: 'text/plain',
    crossDomain: true,
    xhrFields: {
    withCredentials: true
    },

    success: successFunction,
    error: errorFunction
    });


    Please suggest.Also suggest how to implement with webapi. Provide me links as well as steps i need to follow to solve this issue
  • #763174
    Hi Jeevan.

    You can refer below forum links of dotnetspider, the same question has been asked earlier.
    It may help you to achieve your task.

    http://www.dotnetspider.com/forum/337727-Unable-to-Call-Web-Services-Method-Using-Jquery-Ajax-Call.aspx

    http://www.dotnetspider.com/forum/330727-How-call-webservice-webpage-using-Ajax-Jquery.aspx

    http://www.codeproject.com/Articles/529847/Calling-ASP-NET-WebService-from-jQuery

    http://www.codeproject.com/Articles/349598/Introduction-to-using-jQuery-with-Web-Services

    Sridhar Thota.
    Editor: DNS Forum.


Sign In to post your comments