Search code examples
node.jsxmlsoapheader

Getting different response in node.js with "same" request made in SOAP.ui


I have a SOAP request which needs to have an authorization header to be able to make the request.

I've been able to successfully make a request through SOAP.ui setting an header in the Header tab (not with the Header tag).

In node.js, I'm adding the header with addHttpHeader:

client.addHttpHeader('Authorization', httpHeader);

where httpHeader is a token.

When calling the api (through node), I'm getting an error

401: Unauthorized - Token oauth not authenticated

This response is the same as when I make the request (in SOAP.ui) without setting the header (in the header tab) or when I'm setting the header in the xml with:

<Header>
    <Authorization>value of my token </Authorization>
</Header>

When checking my request, the httpHeader is there:

httpHeaders: 
   { Authorization: 'some values' }

What could've been doing wrong to not being able to make the request through node but being able to make it with SOAP.ui?

Is there a way that I could check how the request is being sent in SOAP.ui so I can try to replicate it in node.js


Solution

  • Analizing closely how my request was, the httpHeader 'Authorization' was indeed being sent but in the wrong format. It should be something like

    'Token XXXXXXX'

    but because of the function BasicAuthSecurity that I was calling before adding the httpHeader, it was sending like

    'Basic YYYY'

    Removing the BasicAuthSecurity solved the problem.