简体   繁体   中英

Ajax get request to wsdl web-service

i have wsdl file and i need get data from. How i can do this ? i'm trying do this with ajax like this:

jq.ajax({
   url: 'http://url.wsdl',
   type: 'get',
   success: function(data){
     alert("OK  " + data); 
   },
   error: function (x, y, z) {
     alert("ERROR");
   }
});

what i do wrong ?

Any other way to get data from wsdl web service using javascript, jquery and etc. is?

I think what you are missing is a data: {} I read that there was some sort of bug if you did not include that when using $.ajax Oh, and most likely you are going to need dataType: "json" or whatever datatype the service is using.

Here is an example i am using against an online webservice:

jQuery.support.cors = true; //enables cross domain queries for Ajax
$('#jqueryBtn').click
    (function () 
    {
        $.ajax
            (
                {

                    type: "GET",
                    url: "http://www.webservicemart.com//uszip.asmx/ValidateZip",
                    data: { 'ZipCode': '22553' },
                    dataType: 'html',
                    success: jqSuccess,
                    error: jqError
                }
            );
    }

Hopefully you can use this example to fix your own code

http://forum.jquery.com/topic/jquery-ajax-to-call-a-wsdl-web-service

The following link should explain why you cannot use AJAX for cross domain queries: http://www.w3schools.com/xmL/xml_parser.asp :

Access Across Domains

For security reasons, modern browsers do not allow access across domains.

This means, that both the web page and the file it tries to load, must be located on the same server.

The examples on W3Schools all open XML files located on the W3Schools domain.

If you want to use the example above on one of your web pages, the file you load must be located on your own server.

You can create a proxy web page in your web server to access to WSDL web service and return result to the AJAX request

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM