我已在此处阅读了有关发送 RAW xml 请求的文档:https://www.npmjs.com/package/soap#example-with-xml-string-for-the-args
上面提到的文档中有一个示例:
var args = { _xml: "<ns1:MyRootElement xmlns:ns1="http://www.example.com/v1/ns1">
<ChildElement>elementvalue</ChildElement>
</ns1:MyRootElement>"
};
我也做了同样的事情,并定义了我的参数,但我无法得到 org.xml.sax.SAXParseException;行号:1;列数:390;元素的内容必须包含格式正确的字符数据或标记。 来自 SOAP 服务器的错误消息
这是我的参数定义:
let args = {
_xml: '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://WSDLPROVIDER" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">'
+ '<SOAP-ENV:Body>'
+ '<ns1:enqueue>'
+ '<domain xsi:type="xsd:string">XXXXDOMAINXXXX</domain>'
+'<messageBodies SOAP-ENC:arrayType="xsd:string[1]" xsi:type="SOAP-ENC:Array">'
+ '<item xsi:type="xsd:string">Hello</item>'
+ '</messageBodies>'
+ '<recipientNumbers SOAP-ENC:arrayType="xsd:string[2]" xsi:type="SOAP-ENC:Array">'
+ '<item xsi:type="xsd:string">0936XXXX</item>'
+ '<item xsi:type="xsd:string">0918XXXX</item>'
+ '</recipientNumbers>'
+ '<senderNumbers SOAP-ENC:arrayType="xsd:string[1]" xsi:type="SOAP-ENC:Array">'
+ '<item xsi:type="xsd:string">3000XXX</item>'
+ '</senderNumbers>'
+ '<encodings xsi:nil="true" xsi:type="SOAP-ENC:Array" />'
+ '<udhs xsi:nil="true" xsi:type="SOAP-ENC:Array" />'
+ '<messageClasses xsi:nil="true" xsi:type="SOAP-ENC:Array" />'
+ '<priorities xsi:type="SOAP-ENC:Array" />'
+ '<checkingMessageIds SOAP-ENC:arrayType="xsd:long[2]" xsi:type="SOAP-ENC:Array">'
+ '<item xsi:type="xsd:long">102</item>'
+ '<item xsi:type="xsd:long">103</item>'
+ '</checkingMessageIds>'
+ '</ns1:enqueue>'
+ '</SOAP-ENV:Body>'
+ '</SOAP-ENV:Envelope>'
}
当我尝试 console.log(client.lastRequest)
时,它将返回:
last request: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:impl="http://magfa.com/soap/SOAPSmsQueue" xmlns:intf="http://magfa.com/soap/SOAPSmsQueue" xmlns:tns1="urn:SOAPSmsQueue" xmlns:ns1="http://magfa.com/soap/SOAPSmsQueue"><soap:Header></soap:Header><soap:Body><impl:enqueue>**<$value>**<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://WSDLPROVIDER" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:enqueue><domain xsi:type="xsd:string">XXXXXDOMAINXXXX</domain><messageBodies SOAP-ENC:arrayType="xsd:string[1]" xsi:type="SOAP-ENC:Array"><item xsi:type="xsd:string">Hello</item></messageBodies><recipientNumbers SOAP-ENC:arrayType="xsd:string[2]"
xsi:type="SOAP-ENC:Array"><item xsi:type="xsd:string">09367xxxx</item><item xsi:type="xsd:string">09189xxxx</item></recipientNumbers><senderNumbers SOAP-ENC:arrayType="xsd:string[1]" xsi:type="SOAP-ENC:Array"><item xsi:type="xsd:string">3000xxxx</item></senderNumbers><encodings xsi:nil="true" xsi:type="SOAP-ENC:Array" /><udhs xsi:nil="true" xsi:type="SOAP-ENC:Array" /><messageClasses xsi:nil="true" xsi:type="SOAP-ENC:Array" /><priorities xsi:type="SOAP-ENC:Array" /><checkingMessageIds SOAP-ENC:arrayType="xsd:long[2]" xsi:type="SOAP-ENC:Array"><item xsi:type="xsd:long">102</item><item xsi:type="xsd:long">103</item></checkingMessageIds></ns1:enqueue></SOAP-ENV:Body></SOAP-ENV:Envelope>**</$value>**</impl:enqueue></soap:Body></soap:Envelope>
有什么办法可以发送这个
最佳答案
您可以使用 $xml
键发送原始 XML:
let args = {
$xml: '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://WSDLPROVIDER" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">'
+ '<SOAP-ENV:Body>'
+ '<ns1:enqueue>'
+ '<domain xsi:type="xsd:string">XXXXDOMAINXXXX</domain>'
+'<messageBodies SOAP-ENC:arrayType="xsd:string[1]" xsi:type="SOAP-ENC:Array">'
+ '<item xsi:type="xsd:string">Hello</item>'
+ '</messageBodies>'
+ '<recipientNumbers SOAP-ENC:arrayType="xsd:string[2]" xsi:type="SOAP-ENC:Array">'
+ '<item xsi:type="xsd:string">0936XXXX</item>'
+ '<item xsi:type="xsd:string">0918XXXX</item>'
+ '</recipientNumbers>'
+ '<senderNumbers SOAP-ENC:arrayType="xsd:string[1]" xsi:type="SOAP-ENC:Array">'
+ '<item xsi:type="xsd:string">3000XXX</item>'
+ '</senderNumbers>'
+ '<encodings xsi:nil="true" xsi:type="SOAP-ENC:Array" />'
+ '<udhs xsi:nil="true" xsi:type="SOAP-ENC:Array" />'
+ '<messageClasses xsi:nil="true" xsi:type="SOAP-ENC:Array" />'
+ '<priorities xsi:type="SOAP-ENC:Array" />'
+ '<checkingMessageIds SOAP-ENC:arrayType="xsd:long[2]" xsi:type="SOAP-ENC:Array">'
+ '<item xsi:type="xsd:long">102</item>'
+ '<item xsi:type="xsd:long">103</item>'
+ '</checkingMessageIds>'
+ '</ns1:enqueue>'
+ '</SOAP-ENV:Body>'
+ '</SOAP-ENV:Envelope>'
}
我已经引用了这篇文章 https://stackoverflow.com/a/42143198
以及 node-soap
代码 where it declares an XML key :
public xmlKey = '$xml';
关于node.js - 如何在 Node SOAP 中发送原始 XML 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57946458/
相关文章:
reactjs - 尝试在 react-testing-library 中呈现组件时出错 - 得到一
keras - 在不运行模型的情况下计算 Keras 中的损失
reactjs - props 没有传递给 react native 中的另一个组件
java - 从 jlink 图像创建所有包含 windows 可执行文件
npm - 无法在 Nexus Repository Manager 2.10 上发布库
javascript - 如何转到 Epubjs 中的特定页面
azure-functions - Azure 函数无法在 Azure 门户中下载 PowerShe