【问题标题】:Node-soap XML syntax节点肥皂 XML 语法
【发布时间】:2015-09-16 12:31:36
【问题描述】:

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

现在,关于 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'
}

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

任何帮助将不胜感激。

【问题讨论】:

    标签: xml node.js soap wsdl soap-client


    【解决方案1】:

    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”定义。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多