2014-03-06 98 views
0

我在使用jQuery解析來自SOAP服務器的響應時遇到了問題。使用jQuery解析來自SOAP響應的XML

這是要求

POST /REMEDIFINDERSERVICES/HSWebService.asmx HTTP/1.1 
Host: 192.168.1.24 
Content-Type: text/xml; charset=utf-8 
Content-Length: length 
SOAPAction: "http://www.healthsprint.com/NewUserRegistration" 

<?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> 
<NewUserRegistration xmlns="http://www.healthsprint.com"> 
    <loginId>string</loginId> 
    <Password>string</Password> 
</NewUserRegistration> 
</soap:Body> 
</soap:Envelope> 

,這是響應

HTTP/1.1 200 OK 
Content-Type: text/xml; charset=utf-8 
Content-Length: length 

<?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> 
<NewUserRegistrationResponse xmlns="http://www.healthsprint.com"> 
    <NewUserRegistrationResult>int</NewUserRegistrationResult> 
</NewUserRegistrationResponse> 
</soap:Body> 
</soap:Envelope> 

,這是我的代碼

$("#signup_btn").click(function (event) { 

var fornewUrl = "http://192.168.1.24/REMEDIFINDERSERVICES/HSWebService.asmx?op=NewUserRegistration"; 


var newforsoapRequest = 
'<?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> \ 
<NewUserRegistration xmlns="http://www.healthsprint.com"> \ 
    <loginId>' + $(".user").val() + '</loginId> \ 
    <Password>' + $(".pwd").val() + '</Password> \ 
</NewUserRegistration> \ 
</soap:Body> \ 
</soap:Envelope>'; 


$.ajax({ 
       type: "POST", 
       url: fornewUrl, 
       contentType: "text/xml", 
       dataType: "xml", 
       data: newforsoapRequest, 
       success: newprocessSuccess, 
       error: newprocessError 
      }); 

      function newprocessSuccess(data, status, req) { 
     if (status == "success") 
      $(".u_name").text($(req.responseXML).find("loginId").text()); 

    } 

    function newprocessError(data, status, req) { 
     alert(req.responseText + " " + status); 
    } 

     }); 

我需要發送的數據,登錄ID和密碼,需要顯示登錄ID到其他頁面,但不知何故它不在這裏工作。

數據甚至我怎麼會檢查發送到Web服務或提前

回答

0

感謝我不知道我完全理解這個問題,但SOAP是XML。我想你可以使用XML Parser來標識各個XML元素並進一步使用它。

希望我幫了忙!

+0

我怎麼能檢查這個,在我的數據庫中有三個返回值0,1,2 =重複,1 =成功,2 =未知 –