【发布时间】:2010-01-22 04:12:59
【问题描述】:
所以我试图发出一个请求并传入一个 SOAP 对象,问题是它返回正常(onSuccess)但 responseXML 不存在。我使用了 Fiddler 和 HTTP 客户端(OSX 版本的 fiddler)并输入了相同的请求,繁荣,都返回了正确的响应。有了原型,就没那么多了。
我在标题和参数字段中尝试过...
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript">
function test(){
var body = '<?xml version="1.0" encoding="utf-8"?>' +
'<soap:Envelope' +
' xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"' +
' xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"' +
' xmlns:tns="urn:uvindexalert" xmlns:types="urn:uvindexalert/encodedTypes"' +
' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' +
' xmlns:xsd="http://www.w3.org/2001/XMLSchema">' +
' <soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' +
' <tns:getUVIndexAlertByZipCode>' +
' <in0 xsi:type="xsd:string">92109</in0>' +
' </tns:getUVIndexAlertByZipCode>' +
' </soap:Body>' +
'</soap:Envelope>';
var headers = ["SOAPAction", " ", "Content-Type", "text/xml"];
var request = new Ajax.Request("http://iaspub.epa.gov/uvindexalert/services/UVIndexAlertPort?wsdl", {
contentType: "application/xml",
requestHeaders: headers,
parameters: "SOAPAction: ",
postBody: body,
onSuccess: function(response){
var j = 0;
},
onFailure: function(){
var i = 0;
}
});
}
test();
</script>
var i 和 j 只是为了让我知道它在哪里中断,以便我可以检查它。我也在网上查看并注意到有人说尝试而不是 text/xml application/xml 然后添加 charset=utf-8 所以我做了所有这些但仍然没有。任何人都知道如何使用 SOAPAction 取回 XML?
【问题讨论】:
标签: javascript ajax soap prototypejs