【问题标题】:How to use derived types in node-soap如何在 node-soap 中使用派生类型
【发布时间】:2017-04-24 17:15:54
【问题描述】:

我正在使用 Node Soap https://github.com/vpulim/node-soap 发送 SOAP 请求并解析答案。

现在我有了一个派生类型 <searchedAddress xsi:type="PersonAddressDescription"> 的服务。

如何在我的请求中指定xsi:type="PersonAddressDescription"

这就是我的工作

  const args = {
    searchedAddress: {
      location: {
        street: 'Karl-Theorstraße 88',
        zip: '34234',
        city: 'Rummelshausen'
      },
      firstName: 'Foo',
      lastName: 'Bar'
    }
  }

soap.createClient(WSDL, wsdlOptions, (err, client) => {
  client.getReport(args, (err, result) => {
    if (err !== null) {
      console.log(client.lastRequest)
      reject(err)
    }
    resolve(result)
  })
})

请求应该是这样的:

<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
 <soap:Header/>
  <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <getReportRequest xmlns="http://www.service.com/superservice/v1.00">
      <searchedAddress xsi:type="PersonAddressDescription">
        <location>
          <street>Karl-Theorstraße 88</street>
          <zip>34234</zip>
          <city>Rummelshausen</city>
        </location>
        <firstName>Foo</firstName>
        <lastName>Bar</lastName>
      </searchedAddress>
    </getReportRequest>
  </s:Body>
</s:Envelope>

【问题讨论】:

    标签: node.js web-services soap node-soap


    【解决方案1】:

    尝试将attributes 添加到您请求的节点。来自here

     const args = {
        searchedAddress: {
          attributes: {
            'xsi:type': 'PersonAddressDescription'
            },
          location: {
            street: 'Karl-Theorstraße 88',
            zip: '34234',
            city: 'Rummelshausen'
          },
          firstName: 'Foo',
          lastName: 'Bar'
        }
      }
    

    【讨论】:

    • 这就是解决方案。抱歉,我错过了奖励赏金。我无法及时查看您的解决方案。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多