node.jssoapsoap-clientnode-soap

Node Soap: How to override request payload for SOAP method


I've been shifting between node-soap and strong-soap since they both generate different payloads and work similarly (All I have to do is change the require path and I can shift between strong-soap and node-soap without changing existing code)

However, when I'm using node-soap, I't really does generate these weird payloads.

Here's an exmaple

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:i0="http://services.redacted.com/Contracts" xmlns:msb="http://schemas.microsoft.com/ws/06/2004/mspolicy/netbinary1" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:tns="http://services.redacted.com/Contracts" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soap:Header>
      <stns:SecurityToken xmlns:stns="http://services.redacted.com/Security">
         <ServiceKey>123</ServiceKey>
         <UserId>123</UserId>
         <Username>123</Username>
         <Password>123</Password>
      </stns:SecurityToken>
   </soap:Header>
   <soap:Body>
      <DataService_GetProfiles_InputMessage />
   </soap:Body>
</soap:Envelope>

So it's all fine, except the method I'm trying to invoke is called: GetProfiles not DataService_GetProfiles_InputMessage and subsequently the service I'm trying to communicate with doesn't recognise the method I'm trying to invoke.

What does work (And what strong-soap generates)

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:i0="http://services.redacted.com/Contracts" xmlns:msb="http://schemas.microsoft.com/ws/06/2004/mspolicy/netbinary1" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:tns="http://services.redacted.com/Contracts" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soap:Header>
      <stns:SecurityToken xmlns:stns="http://services.redacted.com/Security">
         <ServiceKey>123</ServiceKey>
         <UserId>123</UserId>
         <Username>123</Username>
         <Password>123</Password>
      </stns:SecurityToken>
   </soap:Header>
   <soap:Body>
      <GetProfiles />
   </soap:Body>
</soap:Envelope>

Now that makes sense. However, due to other constraints we can't stick to strong-soap.

Is there a way I can override the requested payload? Is there a reason It's generating this weird XML?

My Code:

this.dataClientConnection.DataService.BasicHttpBinding_DataService.GetProfiles()


Solution

  • The solution was the following:

    Documentation LIST ITEM 5

    You will however override the entire document you're sending.

    I did not figure out a way to override certain nodes.