这是我需要发送给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
界面中传递消息?
任何帮助将不胜感激。
答案 0 :(得分:2)
假设enqueue是在WSDL中定义的SOAP方法,并且您从node-soap创建的客户端调用它,我会使用类似的东西:
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'
]
}
}
}
}
}