User and Password not passed and basic auth not provided, but I am providing them?

Hello,

I am trying to access a SOAP web service that is hosted locally at my company. In order to access the service I need to pass two header arguments. In SOAP UI I do it like so:


And in Outsystems I am doing it like this:

The SoapHeader.Element values are as follows:

"<x:Fed-Target-System>DEV1</x:Fed-Target-System>"
"<x:Fed-Application-Identifier>FDMSCommonApp</x:Fed-Application-Identifier>"


When running my application I get the error, "User and Password not passed and basic auth not provided" But as you can see I have set basic authentication for the service on the right panel.

I tried following along with this post but cannot seem to get it to work correctly. I'm confused as to what the x: prefix is for and if that is messing things up. 


Any ideas as to how to solve this issue?

Solution

Hi Dan,

Just to confirm, these headers you want to add, are SOAP headers or HTTP headers?

I'll try to answer anyway. So, it seems you have two concerns here:

  • How to add some headers to the request, and
  • Know whether the basic authentication credentials are being sent.

For the first point, you are actually using the wrong action for that. You imported the SOAP service using OutSystems 11, right? For SOAP services consumed version 11, the EnhancedWebReferences extension is deprecated (it should only be used to customize exposed SOAP services).

But you can do what you want using this Forge component, SOAP Extensibility Samples.

You just have to:

  1. Install component from Forge, through Service Studio
  2. Using the Manage Dependencies button, add a reference to Action 'AddSOAPHeader_ToRequest' from SOAPExtensibilitySamples extension
  3. In the service properties, in 'On Before Request' chose option 'New OnBeforeRequest (Advanced)'
  4. Go to the created 'OnBeforeRequestAdvanced' callback
  5. Add to the flow the Action to add the headers, once for each header you want to add. The action depends if you want SOAP or HTTP headers:
    • For SOAP headers, use AddSOAPHeader_ToRequest
    • If HTTP headers, AddHTTPHeader_ToRequest
  6. Pass the correct parameters for the Actions
  7. If you publish the module and try it invoking the SOAP service, it should receive the headers as you specified them.

This article about SOAP extensibility might be helpful: https://success.outsystems.com/Documentation/11/Extensibility_and_Integration/SOAP/Consuming_SOAP_Web_Services/Use_Advanced_Extensibility

About your second point, you can easily see what information is sent in a request by increasing the logging level to Full or Troubleshoot and checking the logs. That way, you can see all the HTTP headers, including the one used for Basic authentication. Check how here: https://success.outsystems.com/Documentation/11/Extensibility_and_Integration/SOAP/Troubleshoot_SOAP_Web_Services


Let me know if this solves your problem.


Cheers,

Pedro Guimarães

Solution

Pedro Guimarães wrote:

Hi Dan,

Just to confirm, these headers you want to add, are SOAP headers or HTTP headers?

I'll try to answer anyway. So, it seems you have two concerns here:

  • How to add some headers to the request, and
  • Know whether the basic authentication credentials are being sent.

For the first point, you are actually using the wrong action for that. You imported the SOAP service using OutSystems 11, right? For SOAP services consumed version 11, the EnhancedWebReferences extension is deprecated (it should only be used to customize exposed SOAP services).

But you can do what you want using this Forge component, SOAP Extensibility Samples.

You just have to:

  1. Install component from Forge, through Service Studio
  2. Using the Manage Dependencies button, add a reference to Action 'AddSOAPHeader_ToRequest' from SOAPExtensibilitySamples extension
  3. In the service properties, in 'On Before Request' chose option 'New OnBeforeRequest (Advanced)'
  4. Go to the created 'OnBeforeRequestAdvanced' callback
  5. Add to the flow the Action to add the headers, once for each header you want to add. The action depends if you want SOAP or HTTP headers:
    • For SOAP headers, use AddSOAPHeader_ToRequest
    • If HTTP headers, AddHTTPHeader_ToRequest
  6. Pass the correct parameters for the Actions
  7. If you publish the module and try it invoking the SOAP service, it should receive the headers as you specified them.

This article about SOAP extensibility might be helpful: https://success.outsystems.com/Documentation/11/Extensibility_and_Integration/SOAP/Consuming_SOAP_Web_Services/Use_Advanced_Extensibility

About your second point, you can easily see what information is sent in a request by increasing the logging level to Full or Troubleshoot and checking the logs. That way, you can see all the HTTP headers, including the one used for Basic authentication. Check how here: https://success.outsystems.com/Documentation/11/Extensibility_and_Integration/SOAP/Troubleshoot_SOAP_Web_Services


Let me know if this solves your problem.


Cheers,

Pedro Guimarães

Thanks for the reply Pedro.


A couple things I learned while solving this problem:


1. I needed HTTP headers, not soap headers. This was mainly my fault and could have been resolved with more research on my end. BUT after making this realization I was still under the impression that the headers weren't working since my SOAP requests were failing. This leads me to number 2.

2. The HTTP headers do not show up in my client browser as they are being sent through the server. I was able to turn up the logging for the module and see what my request was actually looking like and could see that my headers were indeed getting passed through, but the SOAP object I was sending didn't look like it was supposed to.


I also added the headers using SOAPExtensibilitySamples as you recommended and it was very easy.


Followup question: Is there any way to see the request on the client side using Chrome developer tools? Or do I have to stick to changing the logging level on the server?