cancel
Showing results for 
Search instead for 
Did you mean: 

JAVA/ XSLT Mapping to Create a SOAP Envelope

Former Member
0 Kudos

Hello,

I have a File to SOAP scenario and it requires the SOAP message with a custom SOAP envelope. I have searched SDN and could only find that SOAP envelope can be created using a JAVA or XSLT mapping. However, I could not find any blog/ article which will help me understand, with an example, how this is actually coded (creating of a custom SOAP envelope).

Can anyone please point me to a valid blog/ article/ wiki which describes the procedure?

Thanks,

Pankaj.

P.S. Please no spamming of post with links on SOAP Envelope; I have already searched on SDN

Accepted Solutions (1)

Accepted Solutions (1)

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

Here is a wiki using PI 7.1

https://wiki.sdn.sap.com/wiki/display/XI/SampleJAVAMappingcodeusingPI7.1+API

If you want to create a SOAP Envelope, comment out the codes


  private static final DynamicConfigurationKey KEY_FILENAME =
         DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");

String inParam = arg0.getInputParameters().getString("PARAM_IN1");
	getTrace().addInfo("Input Parameter: " +inParam);
	int offset = inData.indexOf(inParam);
	//7. Reader Message ID from Message Header
	InputHeader messageHeader = arg0.getInputHeader();
	String messageId = messageHeader.getMessageId();
	//8. A DynamicConfiguration is a map containing adapter specific message attributes.
	// It associates DynamicConfigurationKeys with string values. The DynamicConfiguration object is obtained using
	// method getDynamicConfiguration()of class com.sap.aii.mapping.api.TransformationInput;
	DynamicConfiguration conf = arg0.getDynamicConfiguration();
	conf.put(KEY_FILENAME, "This Test file is set by JAVA Mapping");
	String outData = "";if(offset > 0){
	int offset1 = inData.indexOf(">", offset);
	String StartString =inData.substring(0,offset1);
	String DocumentNameSpace = " xmlns=\"urn:iso:std:iso:20022:tech:xsd:pain.002.001.02\"";
	String RemainingString = inData.substring(offset1);

lastly, instead of using


outData = StartString + DocumentNameSpace + RemainingString;

replace it with something like this


String outData = "";
outData = "<soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:tem=\"http://yournamespace/\"><soap:Header/><soap:Body>"+inData.substring(inData.indexOf("?>")+2)+"</soap:Body></soap:Envelope>";

Hope this helps,

Mark

Former Member
0 Kudos

Hi Mark,

Thank you for the response!

I just ran into this thread which highlights some more approach:

Thanks,

Pankaj.

Former Member
0 Kudos

Hi,

I have a payload like one given below (should be output of PI):

<?xml version="1.0" encoding="UTF-8" ?> 
    <soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
     <a:Information xmlns:a="http://com/somenamespace">
       <a:Data xmlns:java="somenamespace">
         <java:Container>
           <java:Name>Val1</java:Name> 
           <java:Value>Val2</java:Value> 
         </java:Container>
      </a:Data>
    </a:Information>
   </soapenv:Body>

I am trying to convert this into an XSD but after converting it into XSD (using Stylus Studio) and using it in mapping I am not getting the prefix as soapenv, a, java; the prefixes now get changed to ns0, ns1, ns2.

How should I design the XSD so that the tags required in the envelope remain as I want (shown in above example).

I do not want to include any module to change the prefixes; I would like to handle the envelope in the structure itself.

Thanks,

Pankaj.

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

I am not getting the prefix as soapenv, a, java; the prefixes now get changed to ns0, ns1, ns2.

This is how namespaces are internally handled in PI.

How should I design the XSD so that the tags required in the envelope remain as I want (shown in above example).

Not possible in message mapping part. You have to add XSLT/Java Mapping at the last part of your operation mapping to replace the ns0, ns1 and ns2 to soapenv, a and java respectively.

Hope this helps,

Mark

Former Member
0 Kudos

Hi Mark,

Not possible in message mapping part. You have to add XSLT/Java Mapping at the last part of your operation mapping to 
replace the ns0, ns1 and ns2 to soapenv, a and java respectively.

Ok. So it means that we cannot achieve the requirement by developing a custom structure (xsd) and then referring in mapping. I assumed that if we define the XSD then there was no need of a JAVA mapping; however it seems that we have to make use of JAVA/ XSLT mappings.

Thanks,

Pankaj.

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

Yup, that is correct. Even if you make custom xsd, the namespaces would always get translated to ns0,ns1 and so on.

Regards,

Mark

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello Mr,

I suggest you to use an XSLT mapping.

You can find some instructions in my blog:

http://simonlesflex.wordpress.com/2011/01/26/sap-pi-customize-message-with-xslt-mapping/

Here the Guide to xslt mapping:

http://www.riyaz.net/blog/beginners-guide-to-xslt-mapping-in-sap-pi/technology/sap/769/