function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
vinit_sfvinit_sf 

Need help with SOAP request

Currently I am able to send the Header in the Soap request in 2 ways as shown below:

 

1st way

<env:Header>

            <Security xmlns ="http://schemas.xmlsoap.org/ws/2003/06/secext">

                        <UsernameToken>

                                    <Username>abcde</Username>

                                    <Password>abc123</Password>            (Password here is simple xsd:string type)

                        </UsernameToken>

            </ Security>

</env:Header>

 

And like this:

2nd way

<env:Header>

            <Security xmlns ="http://schemas.xmlsoap.org/ws/2003/06/secext">

                        <UsernameToken>

                                    <Username>abcde</Username>

                                    <Password Type=”PasswordText” />

                        </UsernameToken>

            </ Security>

</env:Header>

 

 

But this is the header that I require (marked in Red):

<env:Header>

            <Security xmlns ="http://schemas.xmlsoap.org/ws/2003/06/secext" soapenv:mustUnderstand="1">

                        <UsernameToken>

                                    <Username>abcde</Username>

                                    <Password Type= “PasswordText”>abc123</Password>

                        </UsernameToken>

            </ Security>

</env:Header>

 

 

What I am unable to create 2 things as shown above:

  1. I can send either password type or password value, but not both together.
  2. I cannot add soapenv:mustUnderstand="1" in Security tag.

Is there way to achieve it by making modification in the Apex class or any other way?

 

I am trying to make callout to a webapplication from salesforce.

 

Thank you.





RajiSrinivasanRajiSrinivasan

I have the same issue. I need to send a complete SOAP XML request with security credentials set in SOAP Header.

 

One workaround is to create the XML request manually (as a string) and send it as a Httprequest.

 

But I would like to know if we can use the standard SOAP APIs to create a complete SOAP request in Apex.