jquery / ajax客户端调用SOAP webservice - 错误

时间:2015-07-28 11:21:42

标签: javascript jquery ajax web-services soap

我想创建一个通过soap请求调用Web服务的简单页面。

<html>
<head>
<title>Calling Web Service from jQuery</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#btnCallWebService").click(function (event) {
            var wsUrl = "/scoring/rest/configuration/bno/score";

            var soapRequest = '<?xml version="1.0" encoding="utf-8"?>' +
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:rem="http://xml.spss.com/scoring-v2/remote" xmlns:scor="http://xml.spss.com/scoring-v2" xmlns:data="http://xml.spss.com/data"> \<soapenv:Header> \
  <wsse:Security soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> \
     <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> \
        <wsse:Username>Native//xy</wsse:Username> \
        <wsse:Password wsse:Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">yx</wsse:Password> \
     </wsse:UsernameToken> \
  </wsse:Security> \
  <ns1:client-accept-language soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xmlns:ns1="http://xml.spss.com/ws/headers">en-US;q=1.0, en;q=0.8</ns1:client-accept-language> \
</soapenv:Header> \
<soapenv:Body> \
  <rem:getScore> \
     <scor:scoreRequest id="bno"> \
<scor:requestInputTable name="input"> \
   <scor:requestInputRow> \
      <scor:input name="szoveg" value="' + $("#txtName").val() + ' "/> \
</scor:requestInputRow> \
</scor:requestInputTable> \
     </scor:scoreRequest> \
  </rem:getScore> \
 </soapenv:Body> \
</soapenv:Envelope>'; $.ajax({
                type: "POST",
                url: wsUrl,
                contentType: "text/xml",
                dataType: "xml",
                data: soapRequest,
                success: processSuccess,
                error: processError
            });

        });
    });

    function processSuccess(data, status, req) {
        if (status == "success")
            $("#response").text($(req.responseXML).find("ns2").text());
    }

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

</script>
</head>
<body>
<h3>
    Calling Web Services with jQuery/AJAX
</h3>
Enter your name:
<input id="txtName" type="text" />
<input id="btnCallWebService" value="Call web service" type="button" />
<div id="response" />
</body>
</html>

问题在于

<scor:input name="szoveg" value="' + $("#txtName").val() + '"    />  \

线。我有几个错误。

有效行似乎是

 <scor:input name="szoveg" value="dafa"/>

问题是我如何编写如上所述的发送代码的代码。当我运行此代码的jquery帖子

 <scor:input name="szoveg" value="dafa">

没有关闭/.

screenshot

0 个答案:

没有答案