cancel
Showing results for 
Search instead for 
Did you mean: 

Reading contents of SOAP Header

Former Member
0 Kudos

Hi folk,

I did some reseach on SDN on how to read the contents of the SOAP header, there were a lot of promising leads but i havn't hit the bull'sEye yet.....

1.i have a requirement whrein i need to read some contents frm the SOAP header hold on to it and send it back in the respnse.

2.2nd requirement i have to modify the soap header's contents based on the current date/time and send it.

Can someone give me some leads/hints on how to achieve this.

If you can give me the mapping API i need to call in the mapping that will be greatly appreciated!!

Thank u all.

Hank

Accepted Solutions (1)

Accepted Solutions (1)

henrique_pinto
Active Contributor
0 Kudos

some quick facts:

#1: there is a confusion between HTTP Headers (which is addressed by the Variable Transport Binding option in both SOAP and HTTP adapters) and the SOAP Header (part of the XML message that is the payload of the HTTP Request). Notice that the SOAP Header is not addressable through the Dynamic Configuration of the HTTP Headers.

#2: in order to read data from the SOAP Header on the outbound (sender) side, you need to:

#2.1. select the "Do Not Use SOAP Envelope" option in the Sender communication channel (the SOAP Envelope has two subtags, the SOAP Header and the SOAP body, which contains the payload);

#2.2. in the mapping, you need to consider the whole SOAP Envelope as source message. You could even try to address it through a Message Mapping, given that you have an external message definition (e.g. wsdl, xsd) that defines the SOAP Envelope layout. But it is much easier to handle it through a XSLT or Java Mapping, at a 1st moment, to read the necessary information from the SOAP Header* and to extract the payload from the SOAP Body, and then use your existing Message Mapping in the payload.

Example of XSLT mapping: (last message)

You just need to enhance the part where you read the header field you need.

Best,

Henrique.

  • to recover the read value at a later point, you could use for example a mapping variable (PI 7.1+) or a custom context object (use dynamic configuration to read/write on a custom context object). Notice that Dynamic Configuration works as a custom HashMap, where you can read/write any combination of context objects namespace/technical name. Just define your custom namespace and technical name (e.g. 'http://sap.sdn.com/test' and 'MyParam'), fill it in the XSLT mapping** and read it afterwards, wherever you need***.

      • if you want to use this value in a Receiver Determination, you can even use Adapter Metadata to define them as "fake ASMAs": /people/michal.krawczyk2/blog/2006/10/09/xi-dynamic-configuration-in-adapter-modules--one-step-further

henrique_pinto
Active Contributor
0 Kudos

Additional info: if you ever get HTTP 415 error with the "Do Not Use SOAP Envelope" flag, check this:

Best,

Henrique.

Answers (1)

Answers (1)

former_member187339
Active Contributor
0 Kudos

Hi Hank,

A good question..I never tried editing the SOAP Header but after seeing your query did some research and found that java has some API to get access SOAP Header.

http://www.j2ee.me/j2ee/1.4/docs/api/javax/xml/soap/SOAPHeader.html

Need to do further RD on the same. In the mean time you can see whether this helps you. One thing is sure we need to use Java mapping and accessing SOAP header in Message Mapping is not possible (since during runtime PI sends only Payload for Message Mapping)

Regards

Suraj

Former Member
0 Kudos

Thnk u for the reply ,

One thing is sure we need to use Java mapping and accessing SOAP header in Message Mapping is not possible (since during runtime PI sends only Payload for Message Mapping)

About this comment you made: i don't thnk we need java mapping , i have seen some treads here on SDN that explain how it can be achieved by using the APIbelow :


DynamicConfiguration conf = (DynamicConfiguration) container
.getTransformationParameters()
.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
 
DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/SOAP","XHeaderName1");
 String value = conf.get(key1);

return value;

i am getting an output "null" though....

lost what to do...

your feeds are very much appreciated guys..thanks again