Skip to Content
0

xslt mapping with java - set value header in soap receiver

May 16, 2017 at 09:07 PM

107

avatar image

Hi Expert,

I want to send user and pass in the header to soap receiver, but it does not work.

I have created the following xslt mapping

	<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	 xmlns:map="java:java.util.Map"
     xmlns:dyn="java:com.sap.aii.mapping.api.DynamicConfiguration"
     xmlns:key="java:com.sap.aii.mapping.api.DynamicConfigurationKey">		 
	<xsl:output method="xml" encoding="utf-8" indent="no"/>	
	<xsl:param name="inputparam"/>
	<xsl:template match="/">
		<xsl:variable name="dynamic-conf"  
        select="map:get($inputparam, 'DynamicConfiguration')" />
		<xsl:variable name="dynamic-key"   
			select="key:create('http://sap.com/xi/XI/System/SOAP', 'XHeaderName1')" />
		<xsl:variable name="dynamic-value" 
			select="dyn:get($dynamic-conf, $dynamic-key)" />
		<xsl:variable name="new-value"     
			select="concat($dynamic-value, 'admin')" />
		<xsl:variable name="dummy" 
			select="dyn:put($dynamic-conf, $dynamic-key, $new-value)" /> 
			
		<xsl:variable name="dynamic-key1"   
			select="key:create('http://sap.com/xi/XI/System/SOAP', 'XHeaderName2')" />
		<xsl:variable name="dynamic-value1" 
			select="dyn:get($dynamic-conf, $dynamic-key1)" />
		<xsl:variable name="new-value1"     
			select="concat($dynamic-value1, 'admin')" />
		<xsl:variable name="dummy1" 
			select="dyn:put($dynamic-conf, $dynamic-key1, $new-value1)" /> 			
	<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">
	   <soapenv:Body>					    	
		<xsl:copy-of select="*" />
	   </soapenv:Body>
	</soapenv:Envelope>
	</xsl:template>
	</xsl:stylesheet>

In the communication channel, I have marked "Do not use SOAP Envelope" and "Keep Headers"

And Activated ASMA

I have marked the option "Use SAP XML Toolkit" in OM

When I run no error appears in sxi_monitor, and generates the following xml without tag header:

But "DynamicConfiguration" is OK.

Finally the response from the webservice indicates that neither user nor paaword has been sent:

Any help will be highly appreciated.

Regards, Joel

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Apu Das May 17, 2017 at 04:42 AM
0

Hi,

Your username and password is static or it will vary?

Thanks,

Apu

Share
10 |10000 characters needed characters left characters exceeded
Evgeniy Kolmakov May 17, 2017 at 07:45 AM
0

Hi Joel!

If your header elements are static you can use AddSOAPHeaderBean to add it to message header:

https://blogs.sap.com/2013/11/22/addsoapheaderbean-module/

Otherwise you should manually construct Header section of SOAP message in your XSL transformation. That's what you set parameter "Do not use SOAP Envelope" for.

Something like this:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<ServiceAuthHeader xmlns="http://WIND.WEBSERVICES.DMS/">
<Username>USER</Username>
<Password>PASSWORD</Password>
</ServiceAuthHeader>
</soap:Header>
<soap:Body>
<xsl:copy-of select="*"/>
</soap:Body></soap:Envelope>
</xsl:template>
</xsl:stylesheet>

Regards, Evgeniy.

Share
10 |10000 characters needed characters left characters exceeded
Joel Jáuregui Hernández May 17, 2017 at 08:39 AM
0

Hi,

Thank you for answering me, when it is static if it works, but the values must be variable and sent from the abap proxy.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hi Joel!

In this case you could use XSL transformation as shown above.

Besides this, SOAP Axis adapter supports header insertion.

Regards, Evgeniy.

0