Monday, 13 March 2017

Overwrite node-soap default envelope's namespace

My wsdl options for creating a client:

const wsdlOptions = {
  envelopeKey: "soapenv",
  overrideRootElement: {
    "namespace": "data",
    "xmlnsAttributes": [
      {
        "name": "xmlns:data",
        "value": "http://www.fleetboard.com/data"
      }
    ]
  }
};

Then I call the method with those options:

const driverRequest = {
      "data:getDriverRequest": {
        attributes: {
          limit: 140,
          offset: 70
        }
      }
    };
clientInstance.getDriver(driverRequest, (error, result, raw, soapHeader) => {
      fs.writeFile('./driverHeader.xml', clientInstance.lastRequest);
    });

The responding request looks like this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tp="http://www.fleetboard.com/data" xmlns:tpns="http://ws.fleetboard.com/BasicService">
  <soapenv:Header></soapenv:Header>
  <soapenv:Body>
    <data:getDriver xmlns:data="http://www.fleetboard.com/data">
      <data:getDriverRequest limit="140" offset="70"></data:getDriverRequest>
    </data:getDriver>
  </soapenv:Body>
</soapenv:Envelope>

But I am trying to achieve this xml:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:data="http://www.fleetboard.com/data">
   <soapenv:Header/>
   <soapenv:Body>
      <data:getDriver>
         <data:GetDriverRequest limit="70" offset="140">
         </data:GetDriverRequest>
      </data:getDriver>
   </soapenv:Body>
</soapenv:Envelope>

How to move the data namespace into the envelope tag?



via Heiki

No comments:

Post a Comment