我正在调用soap web服务之一并且它返回soap响应,而在ajax中解析响应时,我无法做到。它说我无法解析[Object XMLDocument]。我的SOAP方法是将bytes数组发送到客户端。 现在我希望在客户端接收它并从中生成pdf。
我的服务器端代码是
@WebMethod(operationName="purchase")
public byte[] getPurchaseDetails(String personId) throws IOException, ParserConfigurationException, SAXException, XPathExpressionException, TransformerFactoryConfigurationError, TransformerException {
// My business logic
return documentBytes; // Byte array
}
<ns:getResponse xmlns:ns="http://cb.nsib.com" xmlns:ax212="http://sax.xml.org/xsd" xmlns:ax27="http://rmi.java/xsd" xmlns:ax28="http://io.java/xsd">
<ns:return xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmoKPDwvTGVuZ3RoIDMgMCBSL0ZpbHRlci9GbGF0ZURlY29kZT4+CnN0cmVhb
</ns:return>
</ns:getResponse>
我的Ajax代码是
$.ajax({
url: webServiceURL,
type: "POST",
dataType: "xml",
data: 'personId=yyyy',
processData: false,
//contentType: "text/xml; charset=\"utf-8\"",
success: function(data) {
//console.log(data)
console.log(typeof data)
console.log(data)
var xml = data.toString();
console.log(typeof xml)
var xmlDoc = $.parseXML(xml);
console.log(xmlDoc)
console.log($(xmlDoc).find('ns:return').text());
},
error: function() {
}
});
Uncaught Error: Invalid XML: [object XMLDocument]
at Function.error (jquery.min.js:2)
at Function.r.parseXML (jquery.min.js:4)
at Object.success ((index):26)
at i (
如何获取ns中的值:return tag?
请告诉我我在哪里做错了。