cancel
Showing results for 
Search instead for 
Did you mean: 

I need to change Tag description whitout Java Mapping

Former Member
0 Kudos

I have to create a Graphic Mapping in SAP PI 7.1 to change this Java mapping code in Graphic Mapping, because The Client doesn't want any code outside Graphic Mapping

That code change the Tag name y its description from SAP PI to IBM Websphire format

................................................................................................................................................................................................

package com.bancolombia.mapping;

import org.xml.sax.Attributes;

import org.xml.sax.SAXException;

import org.xml.sax.helpers.DefaultHandler;

public class ParsingCAPTACIONES extends DefaultHandler {

String salida = new String();

public void startDocument()

throws SAXException

{

salida += ("<?xml version='1.0' encoding='UTF-8'?>");

}

public void startElement(String namespaceURI, String localName,

String qName, Attributes atts) throws SAXException{

if (localName.equals("Envelope")){

salida += "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:v2=\"http://grupobancolombia.com/ents/SOI/MessageFormat/V2.1\" xmlns:v1=\"http://grupobancolombia.com/intf/Productos/Cuentas/RecuperarCuentas/V1.0\">";

}else if (localName.equals("Header")){

salida += "<soapenv:Header";

for(int i = 0; i < atts.getLength(); i++){

salida += (" " + atts.getLocalName(i) + "=");

salida = ("\""atts.getValue(i)+"\"");

} salida += ">";

}else if (localName.equals("requestHeader")){

salida += "<v2:requestHeader";

for(int i = 0; i < atts.getLength(); i++){

salida += (" " + atts.getLocalName(i) + "=");

salida = ("\""atts.getValue(i)+"\"");

} salida += ">";

}else if (localName.equals("Body")){

salida += "<soapenv:Body";

for(int i = 0; i < atts.getLength(); i++){

salida += (" " + atts.getLocalName(i) + "=");

salida = ("\""atts.getValue(i)+"\"");

} salida += ">";

}else if (localName.equals("recuperarMovimientosCuenta")){

salida += "<v1:recuperarMovimientosCuenta";

for(int i = 0; i < atts.getLength(); i++){

salida += (" " + atts.getLocalName(i) + "=");

salida = ("\""atts.getValue(i)+"\"");

} salida += ">";

}else if (localName.equals("recuperarEstadoCuenta")){

salida += "<v1:recuperarEstadoCuenta";

for(int i = 0; i < atts.getLength(); i++){

salida += (" " + atts.getLocalName(i) + "=");

salida = ("\""atts.getValue(i)+"\"");

} salida += ">";

}else {

salida += "<" + localName;

for(int i = 0; i < atts.getLength(); i++){

salida += (" " + atts.getLocalName(i) + "=");

salida = ("\""atts.getValue(i)+"\"");

} salida += ">";

}

}

public void characters(char ch[], int start, int length) throws SAXException{

String value = new String(ch, start, length);

value = value.replaceAll("<", "&lt;");

value = value.replaceAll(">", "&gt;");

salida += value;

}

public void endElement(String ns, String localName, String qName) throws SAXException{

if (localName.equals("Envelope")){

salida += "</soapenv:Envelope>";

}else if (localName.equals("Header")){

salida += "</soapenv:Header";

salida += ">";

}else if (localName.equals("requestHeader")){

salida += "</v2:requestHeader";

salida += ">";

}else if (localName.equals("Body")){

salida += "</soapenv:Body";

salida += ">";

}else if (localName.equals("recuperarMovimientosCuenta")){

salida += "</v1:recuperarMovimientosCuenta";

salida += ">";

}else if (localName.equals("recuperarEstadoCuenta")){

salida += "</v1:recuperarEstadoCuenta";

salida += ">";

}else{

salida += "</" + localName;

salida += ">";

}

}

public void endDocument(){

}

}

Accepted Solutions (0)

Answers (2)

Answers (2)

stefan_grube
Active Contributor
0 Kudos

You can create an XSD for the required structure and upload this to graphical mapping tool.

Former Member
0 Kudos

I tried to create a XSLT file, but I have problems with this tranformation

if (localName.equals("Envelope")){

salida += "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:v2=\"http://grupobancolombia.com/ents/SOI/MessageFormat/V2.1\" xmlns:v1=\"http://grupobancolombia.com/intf/Productos/Cuentas/RecuperarCuentas/V1.0\">";

or problems with

}else if (localName.equals("Header")){

salida += "<soapenv:Header";

I need to change some Tags name to Tags name (with ":" inside)

anupam_ghosh2
Active Contributor
0 Kudos

Hi ,

Suppose you have a source XML like this below


<?xml version="1.0" encoding="utf-8"?>
		<ns1:MainNode xmlns:ns1="http://example/test">
         		<FirstNode>
         			<Envelope>xyz</Envelope>
         		</FirstNode>
      	</ns1:MainNode>	
	

Now you want to replace this code with XSLT at the same time want tag name with ":" or as per your choice


if (localName.equals("Envelope")){
salida += "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:v2=\"http://grupobancolombia.com/ents/SOI/MessageFormat/V2.1\" xmlns:v1=\"http://grupobancolombia.com/intf/Productos/Cuentas/RecuperarCuentas/V1.0\">";

Then your XSLT code can be something like this


<?xml version="1.0" encoding="ISO-8859-1"?>
 <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<msg_target>
	<xsl:for-each select="//Envelope">
		<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v2="http://grupobancolombia.com/ents/SOI/MessageFormat/V2.1" xmlns:v1="http://grupobancolombia.com/intf/Productos/Cuentas/RecuperarCuentas/V1.0">
		<xsl:value-of select="."></xsl:value-of>	
		</soapenv:Envelope>
	</xsl:for-each>	
</msg_target>	
</xsl:template>	
</xsl:stylesheet>

The output produced will be


<?xml version="1.0" encoding="UTF-8"?><msg_target><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v2="http://grupobancolombia.com/ents/SOI/MessageFormat/V2.1" xmlns:v1="http://grupobancolombia.com/intf/Productos/Cuentas/RecuperarCuentas/V1.0">xyz</soapenv:Envelope></msg_target>         		
      	

you need to add similar code like that of shown as example above for other tags such as "Header".

___________________________________________________________________________________________________________

you wrote "We need to know if this problem has solution with Graphic Mapping or not. If the answer is not, The Client will take desicion or using Java Mapping or change the Tag names?"

You have not described the scenario. Thus it will be difficult to comment whether with graphical mapping you will be able to obtain the target. From the java mapping code you have posted, I can say that this code is extracting required data from a message with SOAP envelop. In such cases grahical mapping is not sufficient, you need a java or an XSLT mapping.

__________________________________________________________________________________________________________

regards

Anupam

Edited by: anupamsap on Oct 6, 2011 6:42 AM

Edited by: anupamsap on Oct 12, 2011 6:47 PM

stefan_grube
Active Contributor
0 Kudos

When your client does not allow Java mapping, will he allow XSLT?

Sorry for being rude, but when you write:

"I need to change some Tags name to Tags name (with ":" inside)"

You should really learn some XML basics before you proceed with your task.

http://www.w3.org/TR/2006/REC-xml-names11-20060816/

Former Member
0 Kudos

No problem Stephan, I understood you answer.

My Client doesn't want neither Java Mapping or XSLT, right now we have solution using Java Mapping, but My Client said "I want solution only with Graphic Mapping".

I am not a expert in .XML structures, in fact The Client has an exclusive department for that, but they using "special characters"for everithing and we have problems when create data types with "special characters" SAP PI only using Letters, Numbers.

In concret, We need to know if this problem has solution with Graphic Mapping or not. If the answer is not, The Client will take desicion or using Java Mapping or change the Tag names?

Thanks

Former Member
0 Kudos

Perfect Anupam

Your coment is enough for my Client, now they going to use XSLT or Java Mapping

Thanks

Former Member
0 Kudos

Hi,

BY using XMLAnonymizer Bean u can do

regards,

ganesh.