Reading the SOAP header when a web service is consumed seems to be an easy task. Nothing could be further from the truth in my case. It really took some time to realize. That is the reason for this blog, to share my thoughts, problems and insides with the community.
System
We use a SAP PI 7.11 SP11 system to realize this scenario.
Context and requirement
It all starts with the requirement to know who consumed a web service and to store that information on the SAP back end system. It means that a user ID must be provided within the SOAP call, but the requirement is not to put this in the message body, but dynamically in the SOAP header.
The input message could look like this
What preceded it were a blog and the follow-up.
*** Important remark Please note that this blog is based on Service Interfaces containing only 1 operation.
Currently, it does not work with multiple operations within 1 service interface.
See Open items and doubts section below.
Configuration
The input structure looks like this
DT_input
Name
The output structure looks like this
DT_output
UserID
Name
The objective is to fill the UserID field with the value of the AuditUser field within the SOAP header. To accomplish this, an XSLT mapping will be used. No other mappings are being used within the Operation Mapping step.
This is the XSLT mapping I used:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl=http://www.w3.org/1999/XSL/Transform xmlns:ns1="namespace">
<xsl:template match="/">
<ns1:DT_output>
<UserID><xsl:value-of select="*/*/AuditUser"/></UserID>
<Name><xsl:value-of select="*/*/DT_input/Name"/></Name>
</ns1:DT_output>
</xsl:template>
</xsl:stylesheet>
Concerning the Integration Directory, a sender SOAP adapter is used and the option Do Not Use SOAP Envelope is enabled.
Also, I added nosoap=true in the URL in soapUI, to allow sending messages in no soap mode. In that case, the SAP PI system puts the complete message in the payload.
After successful tests, I still have some doubts and things I want to clarify…
Open points and doubts
Once these open points and doubts are cleared out, I will update this blog to have everything in 1 place.
[UPDATE]
Just a tip to quickly test/modify an XSLT mapping and immediately see the result: go to XSLT Tutorial and click on the button try it yourself.
On the left side of the screen, put the XML structure entering the SAP PI or PO system. And on the right side of the screen, put your XSLT mapping code.
Press the button Edit and Click me and see the conversion result at the bottom of the screen.
Special thanks go to antonio.sanz for helping me out with the XSLT mapping and the scenario.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
8 | |
7 | |
5 | |
4 | |
4 | |
4 | |
4 | |
3 | |
3 | |
3 |