2011-04-06 102 views

回答

0

檢查call-soap-xm-web-services-with-jquery-ajaxjQuery Plugin SOAP

這裏是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

爲例,用戶還可以查看[鏈接] http://www.bennadel.com/blog/1853-Posting-XML-SOAP - 請求 - 與 - jQuery.htm – mariocase84 2011-04-06 18:40:27

+0

檢查,他們幫助。它也不回答我的問題。你能否給我寫信登錄功能信封,以便我可以看到它是如何工作的?我的服務與鏈接顯示的內容不同。 – Neutralizer 2011-04-06 18:41:15

+0

其實我知道如何發送請求。我想知道創建信封字符串。 – Neutralizer 2011-04-06 18:44:40

相關問題