gpt4 book ai didi

xml - Node SOAP XML 语法

转载 作者:数据小太阳 更新时间:2023-10-29 02:26:06 25 4
gpt4 key购买 nike

我正在尝试使用用 this 定义的 SOAP WebService和 this带有 node-soap 的 WSDL在 node.js 中。

现在,关于 singlewsdl 规范的这一部分:

<xs:element minOccurs="0" name="AuthToken" nillable="true" type="xs:string"/>
<xs:element xmlns:q1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" minOccurs="0" name="NIP" nillable="true" type="q1:ArrayOfstring"/>
...
<xs:element minOccurs="0" name="DateFrom" nillable="true" type="xs:dateTime"/>

使用 AuthToken 或 DateFrom 参数查询服务没有问题:

var args = {
AuthToken: 'yyyy',
DateFrom: (ISOstringed date variable)
};

但我不知道“ArrayOf...”参数的语法应该是什么样子。我试过:

NIP: 'xxxx'
NIP: {
element: 'xxxx'
}
NIP: {
string: 'xxxx'
}

但只有第一个会产生反序列化错误,前者只会产生超时(这与随机参数相同)。

如有任何帮助,我们将不胜感激。

最佳答案

SoapUI帮助我理解了这一点:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:arr="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<soapenv:Header/>
<soapenv:Body>
<tem:GetData>
<tem:AuthToken>xxxx</tem:AuthToken>
<tem:NIP>
<arr:string>yyyy</arr:string>
<arr:string>zzzz</arr:string>
</tem:NIP>
</tem:GetData>
</soapenv:Body>
</soapenv:Envelope>

是所需的 XML 请求格式,所以我让它尽可能接近:

var args = {
attributes: {
'xmlns:arr': 'http://schemas.microsoft.com/2003/10/Serialization/Arrays'
},
'tns:AuthToken': 'xxxx',
'tns:NIP': {
'arr:string': ['yyyy','zzzz']
},
};

作为评论的一句话 - node-soap定义 http://tempuri.org/命名空间默认为“tns”,因此我跳过了 SoapUI 建议的“tem”定义。

关于xml - Node SOAP XML 语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32608712/

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