开发者

WSDL to SOAP Envelope

开发者 https://www.devze.com 2023-02-22 19:01 出处:网络
I have a WSDL web service http://portal.strongtech.com/i/services/ivos?wsdl and I want to send request to functions using AJAX. I know how to send request using AJAX or JQuery though I am not sure how

I have a WSDL web service http://portal.strongtech.com/i/services/ivos?wsdl and I want to send request to functions using AJAX. I know how to send request using AJAX or JQuery though I am not sure how to write SOAP envelope for the function I want to request for.

Can you please help me writing SOAP envelop for the login function from the given service URL? That would be 开发者_StackOverflowreally appreciated.


check call-soap-xm-web-services-with-jquery-ajax and jQuery Plugin SOAP

here is an example from http://www.icloud.com/wiki/index.php/Getting_started_-_jquery_ajax_guide

<html>
  <head>
    <script type="text/javascript" src="http://os.icloud.com/live/jqueryloader.js"></script>
    <script type="text/javascript">
      function printResult(doc, status, xhr) {
        var p = document.getElementById("output");
        if( status == "error" ) {
          p.innerHTML = doc.responseText.replace(/</g, "&lt;");
          login("/", "/"); // reset username
        } else {
          p.innerHTML = xhr.responseText.replace(/</g, "&lt;");
        }
      }

      function createSoapEnvelope(contents) {
        return '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" ' +
          'SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' +
          '<SOAP-ENV:Body>' + contents + '</SOAP-ENV:Body></SOAP-ENV:Envelope>';
      }

      function login(username, password, callback, errback) {
        icloud.ajax({
         type: "POST",
         async: true,
         cache: false,
         contentType: "text/xml; charset=utf-8",
         dataType: "xml",
         processData: false,
         url: "http://os.icloud.com/v1/",
         username: username,
         password: password,
         data: createSoapEnvelope("<login/>"),
         beforeSend: function(xhr) {
           xhr.setRequestHeader("SOAPAction", "login");
         },
         success: callback,
         error: errback
        });
      }

      function buttonClicked() {
        login(document.getElementById("username").value, document.getElementById("password").value, printResult, printResult);
      }
      initIcloudAPI();
    </script>
  </head>
  <body>
    <h2>Login example</h2>
    username:<input type="text" name="username" id="username"/>
    password:<input type="password" name="password" id="password"/>
    <input type="submit" name="login" value="Login" onclick="buttonClicked()"/>
    <p id="output"/>
  </body>
</html>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号