2642
Views
15
Comments
Solved
How to add SOAP header

A web services used in my app requires authentication, how do I add the SOAP headers in the request?

Stanley

2015-12-15 19-07-43
João Amorim
Solution

Hi Stanley

Can you try it like this? 

namespace.png
2018-03-05 03-47-24
Anggun Nurani

João Amorim wrote:

Hi Stanley

Can you try it like this? 

Hi Joao, 

this is my code authantication header in outsystems mobile, 

<x:Envelope xmlns:x="https://schemas.xmlsoap.org/soap/envelope/"
xmlns:tem="https://tempuri.org/">
    <x:Header>
        <tem:AuthHeader>
            <tem:domainName>xxxxx</tem:domainName>
            <tem:userName>xxxxx</tem:userName>
            <tem:password>xxxxxx</tem:password>
        </tem:AuthHeader>
    </x:Header>
    <x:Body>
        <tem:doLogin>
            <tem:JSON_IN>{"username":"qwerty","password":"qwerty"}</tem:JSON_IN>
        </tem:doLogin>
    </x:Body>
</x:Envelope>

how to apply it?

because i got the error like image below


2015-12-15 19-07-43
João Amorim

Hi Stanley

The solution for the problem is what João Neves posted, but we are studying authentication scenarios in SOAP. Can you tell me what kind of authentication your service is using?

UserImage.jpg
Stanley Mok

I am not familiar with the SOAP standards, here is the authentication header:

<soapenv:Envelope xmlns:soapenv="https://schemas.xmlsoap.org/soap/envelope/" xmlns:wsse="https://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
   <soapenv:Header>
  <wsse:Security>
         <wsse:UsernameToken>
           <wsse:Username>XXXXX</wsse:Username>
           <wsse:Password>XXXXX</wsse:Password>
         </wsse:UsernameToken>
  </wsse:Security>
   </soapenv:Header>
   <soapenv:Body>
   </soapenv:Body>
</soapenv:Envelope>

Is there an example how to apply it?


Thanks,

Stanley


2015-12-15 19-07-43
João Amorim

Hi Stanley.

Thank you for your feedback, this will be very helpful for us to improve the platform.

João

Edit: Sorry, I missed the part of the post where you ask for an example. Are you talking about an example of how to use EnhancedWebReferences?

UserImage.jpg
Stanley Mok

João,

I want to know how to use the SetWebReferenceSoapHeaders, how to map the user and password to the structure used in the function.

Thanks,

Stanley

2015-12-15 19-07-43
João Amorim

Hi Stanley

See if the attached image can help you.

webref.png
UserImage.jpg
Stanley Mok

I got "wsse is an unknown prefix" error. If it is removed then it cannot connect to the server.

2015-12-15 19-07-43
João Amorim
Solution

Hi Stanley

Can you try it like this? 

namespace.png
2018-03-05 03-47-24
Anggun Nurani

João Amorim wrote:

Hi Stanley

Can you try it like this? 

Hi Joao, 

this is my code authantication header in outsystems mobile, 

<x:Envelope xmlns:x="https://schemas.xmlsoap.org/soap/envelope/"
xmlns:tem="https://tempuri.org/">
    <x:Header>
        <tem:AuthHeader>
            <tem:domainName>xxxxx</tem:domainName>
            <tem:userName>xxxxx</tem:userName>
            <tem:password>xxxxxx</tem:password>
        </tem:AuthHeader>
    </x:Header>
    <x:Body>
        <tem:doLogin>
            <tem:JSON_IN>{"username":"qwerty","password":"qwerty"}</tem:JSON_IN>
        </tem:doLogin>
    </x:Body>
</x:Envelope>

how to apply it?

because i got the error like image below


UserImage.jpg
Stanley Mok

It works. Thanks João.

The web services use separate services for authentication and the actual service. The authentication works and returns a token to be used in the service calls. However, the service call failed because it is trying to call the localhost. Yet both web services are imported from the same server. How to fix this?



UserImage.jpg
Stanley Mok

I believe the import is not complete because I got the following error during importing:


2022-09-13 13-22-59
Juliano Custódio Parreira

Hi João.

I used "SetWebReferenceSoapHeaders" at a .NET stack and it worked perfectly. But I tried the same implementation at a Java stack, with the same WS, and it did not worked.

Do you know if there are any problem with this in the Java stack?

My case is similar to that described by Stanley.

Best regards.
Juliano

2019-11-12 17-31-26
Justin James
 
MVP

Juliano Custódio Parreira wrote:

Hi João.

I used "SetWebReferenceSoapHeaders" at a .NET stack and it worked perfectly. But I tried the same implementation at a Java stack, with the same WS, and it did not worked.

Do you know if there are any problem with this in the Java stack?

My case is similar to that described by Stanley.

Best regards.
Juliano


This thread is long, and Stanley reported a number of issues. What exact issue are you having?

J.Ja

2016-07-28 15-12-47
CasaSpider

Hi João Amorim,

Today I encountered the same challenge with authentication in the header. Your png-files helped me go thru it. Important is to include the namespace alias. Then it worked like a charm.

Thanks and regards,

Peter Nijhuis.

UserImage.jpg
Asad Syed Ali

Hi,

is there a way I can add my xmlns attribute in <soap:Envelope> element in Consume SOAP web service and send my own request with additional namespaces like below?

<soap:Envelope
xmlns:soap="https://www.w3.org/2003/05/soap-envelope"
xmlns:typ="https://webservices.com/wsrv/common/types"
<soap:Header>

      <typ:MessageHeader>

         <typ:APPId>DATASYSTEM</typ:APPId>

</soap:Envelope>


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.