cancel
Showing results for 
Search instead for 
Did you mean: 

xslt mapping with java - set value header in soap receiver

former_member442887
Discoverer
0 Kudos

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

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member442887
Discoverer
0 Kudos

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.

former_member190293
Active Contributor
0 Kudos

Hi Joel!

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

Besides this, SOAP Axis adapter supports header insertion.

Regards, Evgeniy.

former_member190293
Active Contributor
0 Kudos

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.

apu_das2
Active Contributor
0 Kudos

Hi,

Your username and password is static or it will vary?

Thanks,

Apu