cancel
Showing results for 
Search instead for 
Did you mean: 

SOAP Header with authentication

former_member198445
Participant
0 Kudos

Hello experts,

I am trying to consume an external web service in SAP PI (Proxy -> SOAP). The web service uses SOAP 1.1 and has the following SOAP header:

<soapenv:Header>

      <urn:AuthenticationInfo>

         <urn:userName> </urn:userName>

         <urn:password> </urn:password>

         <!--Optional:-->

         <urn:authentication>?</urn:authentication>

         <!--Optional:-->

         <urn:locale>?</urn:locale>

         <!--Optional:-->

         <urn:timeZone>?</urn:timeZone>

      </urn:AuthenticationInfo>

   </soapenv:Header>

My question is if I can fill the SOAP Header from the proxy consuming ABAP program or do I have to wrote an XSLT mapping for this?

Or, alternatively, will the SOAP Receiver adapter automatically fill the credentials if I maintain the Authentication details in the ID Communication channel?

Looking forward to your responses.

Regards..

Accepted Solutions (1)

Accepted Solutions (1)

former_member198445
Participant
0 Kudos

Hello experts.

I have used an XSLT mapping and have managed to generate the request message.

Now I have an issue with the response.

My response structure is:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

   <soapenv:Body>

      <ns0:UpdateTaskResponse xmlns:ns0="urn:EQU:SAP:UpdateTask">

         <ns0:Request_ID>000000000000008</ns0:Request_ID>

      </ns0:UpdateTaskResponse>

   </soapenv:Body>

</soapenv:Envelope>

I am unable to map this to my response message type.

I tried using this XSLT:

<?xml version="1.0"?>

<xsl:stylesheet xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:output encoding="UTF-8" method="xml"/>

    <xsl:template match="*">

      <xsl:copy-of select="soap:Body/*"/>

    </xsl:template>

</xsl:stylesheet>

But I am still not able to process the response.

Any help on this please?

former_member198445
Participant
0 Kudos

I finally got this scenario working.

The issue was that, in spite of ticking the ‘Do not use SOAP envelope’ checkbox, the response message was wrapped in a SOAP envelope. Also, my endpoint URL in the SOAP comm channel wasn’t the correct one ( I had wrongly used the WSDL link and not the endpoint).

So I changed the URL and then created an inbound XSLT for removing the SOAP envelope from the response message.

The XSLT mentioned in my previous response worked a charm.

I picked up both the XSLTs from Simone Pantaleoni's responses in other threads..

Thanks to all..

Answers (2)

Answers (2)

azharshaikh
Active Contributor
0 Kudos

Hi Amith,

In your scenario i believe you need to add SOAP Header. Adding User name /pwd in CC will not suffice..Please check the following links for various ways to add SOAP Header:

Hope it helps.

Regards,

Azhar

former_member181985
Active Contributor
0 Kudos
former_member198445
Participant
0 Kudos

Thank You Praveen.

My question is do I really have to do this?  I don't want to customize the header structure as such.  I only want to pass the Username and password.

While importing the external definitions, I get the soap header in the interface message type. Can't I just map this to the proxy outbound structure and send the values from the calling ABAP program?

Appreciate your answers..

iaki_vila
Active Contributor
0 Kudos

Hi Amith,

If i understand you right you only want to pass-thorough the header to the ABAP proxy. You only need to set in the SOAP adapters the flag Keep Headers. Later in the ABAP proxy you can get the Header with the class IF_WSPROTOCOL_WS_HEADER. You have some examples in these threads:

Hope this helps.

Regards.

former_member198445
Participant
0 Kudos

Thanks Inaki, Appreciate your response.

Aren't the examples that you have provided for Non-PI scenario? I have used this in the past to consume a WS directly in ABAP, after creating logical port, etc.

Well,in this scenario i am using PI.

The Sender in my case is a proxy (called from a BADI) and receiver would be a SOAP adapter.

What I am trying to get at is the header would be a part of my request structure - like this:

Isn't it possible to just map the oubound and inbound structures and pass the data while calling the outbound proxy?

CALL METHOD lr_proxy->execute

       EXPORTING

         output = output (this is where the uname and password would go)


Sorry if I have misunderstood your response.

Regards,

Amith

azharshaikh
Active Contributor
0 Kudos

Hi Amith,

Can you try to do a test with the approach you mentioned and check the results...from SPROXY try to push the User ID/pwd and map it to the fields in the Target SOAP structure and check the status in Channel logs if it helps..

Regards,

Azhar

iaki_vila
Active Contributor
0 Kudos

Hi Amith,

As far as i know you can not treat the header as part of your method Execute because the header is not part of the payload.

As you i haven't tried to change the header in a PI proxy, but i can find the class to change the header in the proxy class:

Regards.

former_member198445
Participant
0 Kudos

You're right Inaki,

I am only able to map the Sender message type to one of the WS message types i.e. either the header or payload or response.

I will try the solution provided by Praveen or maybe use an XSLT mapping and get back..

Regards,

Amith