节点肥皂:如何创build具有特定属性的复杂消息?

这是我需要发送给wsdl的消息:

 <?xml version="1.0" encoding="UTF-8" ?> <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">STH</domain> <messageBodies SOAP-ENC:arrayType="xsd:string[1]" xsi:type="SOAP-ENC:Array"> <item xsi:type="xsd:string">STHE</item> </messageBodies> <recipientNumbers SOAP-ENC:arrayType="xsd:string[2]" xsi:type="SOAP-ENC:Array"> <item xsi:type="xsd:string">09xxxxxxxx</item> <item xsi:type="xsd:string">09xxxxxxxx</item> </recipientNumbers> <senderNumbers SOAP-ENC:arrayType="xsd:string[1]" xsi:type="SOAP-ENC:Array"> <item xsi:type="xsd:string">3000xxxxx</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">100</item> <item xsi:type="xsd:long">101</item> </checkingMessageIds> </ns1:enqueue> </SOAP-ENV:Body> </SOAP-ENV:Envelope> 

到目前为止,我已经这样做了:

 var args = { domain: 'STHE', messageBodies: { item: { attributes: { 'xsi:type': 'xsd:string' }, $value: "hi" } }, "recipientNumbers": { attributes:{ "SOAP-ENC:arrayType": "xsd:string[2]", "xsi:type": "SOAP-ENC:Array" }, "item": { attributes:{ "xsi:type": "xsd:string" }, $value: "09xxxxxx" } }, "senderNumbers": { attributes:{ "SOAP-ENC:arrayType": "xsd:string[1]", "xsi:type": "SOAP-ENC:Array" }, "item": { attributes: { "xsi:type": "xsd:string" }, $value: "30xxxxx" } 

结果如下:

 <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:impl="WSDLPROVIDER" xmlns:intf="WSDLPROVIDER" xmlns:tns1="urn:SOAPSmsQueue"> <soap:Header></soap:Header> <soap:Body> <impl:enqueue> <domain>STHE</domain> <messageBodies> <item xsi:type="xsd:string">hi</item> </messageBodies> <recipientNumbers> <item xsi:type="xsd:string">09xxxxxx</item> </recipientNumbers> <senderNumbers> <item xsi:type="xsd:string">30xxxxx</item> </senderNumbers> </impl:enqueue> </soap:Body> </soap:Envelope> 

我试图使用messageBodies部分的属性,但我使用的任何组合失败,输出没有任何变化。

有没有什么办法来传递消息在XML而不是Json接口?

任何帮助将不胜感激。

假设enqueue是一个在WSDL中定义的SOAP方法,并且您正在从node-soap创build的客户端调用它,那么我将使用类似如下的方法:

 args: { attributes: { '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/' }, $value: { 'domain': { attributes: {'xsi:type':'xsd:string'}, $value: 'STH' }, 'messageBodies': { attributes: { 'SOAP-ENC:arrayType':'xsd:string[1]', 'xsi:type':'SOAP-ENC:Array' }, $value: { 'item': { attributes: {'xsi:type':'xsd:string'}, $value: [ 'STHE' ] } } }, 'recipientNumbers': { attributes: { 'SOAP-ENC:arrayType':'xsd:string[2]', 'xsi:type':'SOAP-ENC:Array' }, $value: { 'item': { attributes: {'xsi:type':'xsd:string'}, $value: [ '09xxxxxxxx', '09xxxxxxxx' ] } } }, 'senderNumbers': { attributes: { 'SOAP-ENC:arrayType':'xsd:string[1]', 'xsi:type':'SOAP-ENC:Array' }, $value: { 'item': { attributes: {'xsi:type':'xsd:string'}, $value: [ '3000xxxxx' ] } } }, 'encodings': { attributes: { 'xsi:nil':'true', 'xsi:type':'SOAP-ENC:Array' } }, 'udhs': { attributes: { 'xsi:nil':'true', 'xsi:type':'SOAP-ENC:Array' } }, 'messageClasses': { attributes: { 'xsi:nil':'true', 'xsi:type':'SOAP-ENC:Array' } }, 'priorities': { attributes: { 'xsi:type':'SOAP-ENC:Array' } }, 'checkingMessageIds': { attributes: { 'SOAP-ENC:arrayType':'xsd:long[2]', 'xsi:type':'SOAP-ENC:Array' }, $value: { 'item': { attributes: {'xsi:type':'xsd:long'}, $value: [ '100', '101' ] } } } } }