当前位置 : 主页 > 网页制作 > Nodejs >

node.js – 如何在node-soap中使用派生类型

来源:互联网 收集:自由互联 发布时间:2021-06-16
我正在使用Node Soap https://github.com/vpulim/node-soap发送SOAP请求并解析答案. 现在我有一个具有派生类型 searchingAddress xsi:type =“PersonAddressDescription”的服务. 如何在我的请求中指定xsi:type
我正在使用Node Soap https://github.com/vpulim/node-soap发送SOAP请求并解析答案.

现在我有一个具有派生类型< searchingAddress 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>
尝试将属性添加到您请求的节点.从 here起

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