gpt4 book ai didi

xml - Node SOAP : How to create a complex message with specific attributes?

转载 作者:搜寻专家 更新时间:2023-11-01 00:41:40 25 4
gpt4 key购买 nike

这是我需要发送到 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 接口(interface)传递消息吗?

任何帮助将不胜感激。

最佳答案

假设 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'
]
}
}
}
}
}

关于xml - Node SOAP : How to create a complex message with specific attributes?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32122566/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com