当尝试使用 jQuery AJAX 调用 SOAP Web 服务时,为什么请求正文为空?
我已经构建了一个完整的肥皂信封 soapEnvelopeXML
并且我可以看到通过我的 TCP/IP 监视器进行的调用,但问题是请求 URI 不是调用正确的方法,而是与 < code>soapEnvelopeXML 就好像它是标头中的一个选项。所以我没有得到任何结果。我不想将参数作为 JSON 对象传递。关于我可能出错的地方有什么想法吗?
$.ajax({
type: "GET",
url: "http://localhost:8080/webservice/serviceName/",
data: soapEnvelopeXML,
contentType: "text/xml",
dataType: "xml",
error: function(xhr, status, error) {
alert("Error processing your request: \n" + status + " : " + error);
},
success: function(response){
var xml = $(response);
alert(xml);
}
});
我已经测试了上面的代码以使用 POST 而不是 GET,但我得到了一个空响应,并且我看到正在进行一个空的 Web 服务调用。我不知道 GET 对于 SOAP 请求来说是非法的。有谁知道为什么发送的内容是空的呼叫?
I have constructed a full soap envelope soapEnvelopeXML
and I can see the call come through my TCP/IP Monitor, but the issue is that instead of calling the right method, the request URI comes in concatenated with the soapEnvelopeXML
as if it is an option in the header. So i am not getting any result. I don't want to pass in the parameters as JSON objects. Any ideas on where i could be going wrong?
$.ajax({
type: "GET",
url: "http://localhost:8080/webservice/serviceName/",
data: soapEnvelopeXML,
contentType: "text/xml",
dataType: "xml",
error: function(xhr, status, error) {
alert("Error processing your request: \n" + status + " : " + error);
},
success: function(response){
var xml = $(response);
alert(xml);
}
});
I have tested the code on top to use POST instead of GET but I was getting an empty response and I see that an empty webservice call was being made. I didnt know that GET was illegal for SOAP requests. Does anyone know why the sent content is an empty call?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
也许问题在于 SOAP 应该是 POST?
http://www.coderanch.com/ t/463869/Web-Services/java/SOAP-request-as-HTTP
更新:
如果我转到本地主机,我在本地机器上会得到相同的行为,但我通过这样做来使其工作:
127.0 .0.1
尝试此代码,它对我有用:
我从这里获得了此代码:
Maybe the problem is that SOAP should be POST?
http://www.coderanch.com/t/463869/Web-Services/java/SOAP-request-as-HTTP
Update:
I am getting the same behavior on my local box if I go to localhost, but I got it working by doing this:
127.0.0.1
Try this code, it is working for me:
I got this code from here:
它与 URL 连接的原因是
GET
方法的含义。将其更改为 POST,我怀疑它对您有用。
The reason it is concatenated with the URL is that is what the
GET
method means.Change this to POST and I suspect it will work for you.