我正在尝试调用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
提前感谢您的帮助。