How add soap header in response (NodeJS y Strong-soap)

82 views Asked by At

I am using strong-soap as server in node js, i need a pass throught service to convert xml to json (soap call to rest call, i used asyn method) but i need to respond soap incoming request with a response with headers.

I used the async function providen by documentation.

var myService = {
      MyService: {
          MyPort: {

              // This is how to define an asynchronous function, i can get the incoming headers but i dont send the response with headers.
              MyAsyncFunction: function(args, callback, headers) {
                  // do some work
                  callback({
                      name: args.name
                  });
              },

          }
      }
  };

incoming soap request (body and headers) -> soap response (body and headers) <-

How can i do this?

I am searching about this but i did not find nothing. I tried sending another parameter to the callback function

1

There are 1 answers

0
Jonnathan Sandino On

The response was...

const server = soap.listen(...);

const addResponseSoapHeaders = (headers: string | Object) => {
  // We need to clear previous headers (Headers in response will be accumulated from previous responses if we dont clear)
  server.clearSoapHeaders();
  // Add Headers to response
  server.addSoapHeader(headers);
}