我正在尝试调用 SOAP Web 服务。我在soapUI中尝试过它并且效果很好,所以我知道这是我非常简单的代码中的一个问题,加上我对它缺乏理解。
当我按下应该调用“signOn”的“测试”按钮时,我没有得到任何回应。我认为我的问题更多是 jQuery 问题而不是 SOAP 调用问题,因为 SOAP 片段已经在soapUI 中工作。
这是我的代码:
<html>
<head>
<title>SOAP JavaScript Client Test</title>
</head>
<body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
function OnSuccess(data, status) {
alert(data.d);
}
function signOn() {
// build SOAP request
var username = 'admin';
var password = 'mypass';
var webServiceURL = 'https://192.168.10.111:8090/services/AdminMgmtService/AdminMgmt';
var soapMessage = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:omi="http://www.verimatrix.com/omi" xmlns:omit="http://www.verimatrix.com/schemas/OMItypes.xsd">' +
'<soapenv:Header/>' + '<soapenv:Body>' + '<omi:signOn>' +
'<userAttributes>' +
'<omit:userName>' + username + '</omit:userName>' +
'<omit:password>' + password + '</omit:password>' +
'</userAttributes>' + '</omi:signOn>' + '</soapenv:Body>' + '</soapenv:Envelope>';
$.ajax({
url: webServiceURL,
type: "POST",
dataType: "xml",
data: soapMessage,
processData: true,
contentType: "text/xml; charset=\"utf-8\"",
success: OnSuccess,
error: OnError
});
}
</script>
<form name="Demo" action="" method="post">
<div>
<input type="button" value="test" onclick="signOn();" />
</div>
</form>
</body>
<html>
Firebug 返回响应:
OPTIONS AdminMgmt
200 OK
192.168.10.111:8090
0 B
192.168.10.111:8090
Response Headersview source
Allow GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS
Content-Length 0
Date Mon, 10 Dec 2012 02:18:52 GMT
Server Apache-Coyote/1.1
Request Headersview source
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding gzip, deflate
Accept-Language en-US,en;q=0.5
Access-Control-Request-He... content-type
Access-Control-Request-Me... POST
Cache-Control no-cache
Connection keep-alive
Host 192.168.10.111:8090
Origin null
Pragma no-cache
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0
预先感谢您的帮助。