cancel
Showing results for 
Search instead for 
Did you mean: 

How can I get SessionID from SOAP Header in MessageMapping

AntonioSanz
Active Participant
0 Kudos

Hello experts,

I've got a Abap Proxy --> PI --> WebService scenario. I do the call to the web service and it returns me the data and a SessionID in the SOAP header. I've got a message mapping for the response, and in this message mapping I need to get this sessionID because I have to use it later.

I have tried with a UDF with this code:

String headerField = "";

try

{

  String key="SessionID";

  java.util.Map map;

  // get runtime constant map

  map = container.getTransformationParameters();

  // get value of header field by using variable key

  headerField = (String) map.get(key);

}

catch(Exception e){}

if(headerField==null)

{

    headerField = "";

}

return headerField;

But it returns me nothing.

In sxmb_moni I can see the sessionID (see attached file), so It should be possible to access it.

How can I do to get this data????

Many thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

You can  not read that value using UDF in PI. If the session id is present in the dynamic configuartion

part in message header, then you will be able to read it .

In the SOAP adapter, check the option keep header and then see if you receive the session information in dynamic header or not.

AntonioSanz
Active Participant
0 Kudos

Hello Indrajit, I have change the receiver SOAP channel and I have checked keep headers and now I get a mapping error: NO_MAPPINGPROGRAM_FOUND


Mapping program is not available in runtime cache: Object ID 1655B61D7C293ACB9A2CB07674E7690F Software Component C9DF1E70C3B011E3B98FE1280A05006F


Any suggestions??

Former Member
0 Kudos

Hi

This is a different issue. Execute transaction SXI_CACHE and check that the mapping is present there in the run-time cache or not.

Check in ESR and make sure there is no failed cache notification. Also try to make a cache refresh in PI.

AntonioSanz
Active Participant
0 Kudos

Thanks Indrajit.

I have found a solution. I have to use the option: Do Not Use SOAP Envelope in my communication channel.

But as I am using web services I have to create the SOAP Envelope in my mapping (in request and in response).

I have created 2 xslt mapping files: one for request and one for response. The xslt mapping for the request it is placed in second position in my operation mapping. This xslt maping just move the fields and add the soap envelope (header and body, and inside the body places the data from 1st mapping).

The response xslt mapping it is placed directly in my operation mapping (in response area). It transforms the SOAP response into my Message Type.

Here you can find my xslt for request (sessionID, in0, in1 and in2 are fields from my source message type):

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

  <xsl:template match="/">

    <SOAP:Envelope xmlns:SOAP="http://www.w3.org/2003/05/soap-envelope">

      <SOAP:Header>

     <ses:sessionIDHeader xmlns:ses="http://xml.apache.org/axis/session">

             <sessionID><xsl:value-of select="*/sessionID"/></sessionID>

         </ses:sessionIDHeader>

      </SOAP:Header>

      <SOAP:Body>

      <ser:invokeService xmlns:ser="http://www.w3.org/2003/05/soap-envelope">

         <in0><xsl:value-of select="*/in0"/></in0>

         <in1><xsl:value-of select="*/in1"/></in1>

         <in2><xsl:value-of select="*/in2"/></in2>

      </ser:invokeService>

      </SOAP:Body>

    </SOAP:Envelope>

  </xsl:template>

</xsl:stylesheet>

Here is xslt for response (invokeServiceReturn,sessionIDare fields from my target message type):

<?xml version="1.0" encoding="UTF-8"?>

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

  <xsl:template match="/">

    <ns1:MT_invokeServiceResponse xmlns:ns1="http://saras.com/pi/creditoycaucion">

        <invokeServiceReturn><xsl:value-of select="/*/*/*/invokeServiceReturn"/></invokeServiceReturn>

        <sessionID><xsl:value-of select="*/*/*/sessionID"/></sessionID>

    </ns1:MT_invokeServiceResponse>

  </xsl:template>

</xsl:stylesheet>

Kind Regards.

Answers (0)