on 07-03-2007 5:16 PM
Hi,
I am creating Target XML message (in cXML format) from Source XML message (XI XML Format). Now On target I want to Remove Namespace tag: (<ns2:MT_SRM_SCIQUEST_PO_SEND xmlns:ns2="http://abcd.com/PO/sendPO" version="2.0">)
and Replace it with: <!DOCTYPE PurchaseOrderMessage SYSTEM "http://abcd.com/PO/sendPO">
After Replacing I want to add one more Tag like: <PurchaseOrderMessage version="2.0">
in the Message.
Can anybody tell me how can I do this?
I am using receiver plain HTTP Adapter and No sender adapter as sender side it is Proxy that sends XML Message to Integration server.
Any help will be appreciated.
Thanks.
-Adrean.
Hello Adrean,
Check if this transformation helps..
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns2="http://abcd.com/PO/sendPO" exclude-result-prefixes="ns2">
<xsl:template match="ns2:MT_SRM_SCIQUEST_PO_SEND ">
<PurchaseOrderMessage version="2.0">
<xsl:copy-of select="./*"/>
</PurchaseOrderMessage>
</xsl:template>
</xsl:stylesheet>
This should avoid the root element and copy rest of the XML as it is and for <!IDOC you can add it with an XSL comment.
Regards,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I was able to do all other things except to add <!DOCTYPE PurchaseOrderMessage SYSTEM "http://abcd.com/PO/sendPO"> element at the start of Document.
Other things are achieved by exporting XSD of exeisting Message type and editing in XMLSpy. But adding the <!DOCTYPE ... ...> element is not supported. as after adding that tag in XSD it is not imported successfully in to XI. without that tag it gets imported successfully. So I am thinking I have to some how add that tag in Mapping. The position will be like this.
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE PurchaseOrderMessage SYSTEM "http://abcd.com/PO/sendPO">
<PurchaseOrderMessage version="2.0">
<...>
<.../>
</PurchaseOrderMessage>
Any Idea how to achieve this.
Thanks.
-Adrean.
Hey
will it be ok if you get <!DOCTYPEPurchaseOrderMessageSYSTEM"http://abcd.com/PO/sendPO"> instead of <!DOCTYPE PurchaseOrderMessage SYSTEM "http://abcd.com/PO/sendPO">
If yes,then u can simply add the tag in ur xsd(make sure there are no spaces in between).
to get <!DOCTYPE PurchaseOrderMessage SYSTEM "http://abcd.com/PO/sendPO"> i guess u need to do some java mapping.
Thanx
Ahmad
Hi Adrean,
Yes you can do it ...
but try with the Java mapping instead ...
For this you have create a java file like similar to this
import java.io.*;
import java.util.Map;
import java.util.HashMap;
import com.sap.aii.mapping.api.AbstractTrace;
import com.sap.aii.mapping.api.StreamTransformation;
import com.sap.aii.mapping.api.StreamTransformationConstants;
public class addNamespace implements StreamTransformation {
private final String auditStr = "addNamespace - ";
AbstractTrace trace;
private Map param = null;
public void setParameter(Map param)
{
this.param = param;
if (param == null)
{
this.param = new HashMap();
}
}
public void execute(InputStream in, OutputStream out)
{
//Trace
trace = (AbstractTrace) param.get(StreamTransformationConstants.MAPPING_TRACE);
trace.addWarning(auditStr + "Process started");
try {
StringBuffer strbuff = new StringBuffer();
byte[] b = new byte[4096];
for (int n; (n = in.read(b)) != -1;) {
strbuff.append(new String(b, 0, n));
}
String xmlIn = "";
xmlIn = strbuff.toString();
String xmlOut = "";
xmlOut = xmlIn.substring(0,xmlIn.indexOf("><Header>")) + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"schema/xyz.xsd\"" + xmlIn.substring(xmlIn.indexOf("><Header>"));
out.write(xmlOut.getBytes());
trace.addWarning(auditStr + "Process completed successfully");
}
catch (Exception e) {
trace.addWarning(auditStr + "Error while extracting content - " + e.getMessage());
}
}
Note this is just for adding namespace ...
add small code which can remove the namespace also...
Now after this Compile the Java code and Zip the .java and .cls file and import into XI ... Imorted archive..
Use this in Interface mapping after the message Mapping...
Regards,
srihdar
}
Hi,
I am using Netweaver Developer Studio. Though I am not sure how to get .cls file...
Can you please let me know how to get .cls file?
I have created a package, then created a class under that and now i can eport the .jar of that class from NWDS but what about .cls file?
Also I can remove the namespace by modifying XSD but now I will use this code to insert <!DOCTYPE ........> node at the start of document.
Thanks.
-Adrean.
Hi I tired that and did Interface Mapping and it is giving me following error while testing Interface mapping.
Could you please let me know what went wrong?
14:26:30 Start of test
LinkageError at JavaMapping.load(): Could not load class: SOLO/com/sap/xi/intmap/xmlpo/addDoctype
java.lang.NoClassDefFoundError: SOLO/com/sap/xi/intmap/xmlpo/addDoctype (wrong name: com/sap/xi/intmap/xmlpo/addDoctype) at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:539) at java.lang.ClassLoader.defineClass(ClassLoader.java:448) at com.sap.aii.ibrep.server.mapping.ibrun.RepMappingLoader.findClass(RepMappingLoader.java:175) at java.lang.ClassLoader.loadClass(ClassLoader.java:289) at java.lang.ClassLoader.loadClass(ClassLoader.java:235) at com.sap.aii.ibrep.server.mapping.ibrun.RepJavaMapping.load(RepJavaMapping.java:136) at com.sap.aii.ibrep.server.mapping.ibrun.RepJavaMapping.execute(RepJavaMapping.java:50) at com.sap.aii.ibrep.server.mapping.ibrun.RepMappingHandler.run(RepMappingHandler.java:80) at com.sap.aii.ibrep.server.mapping.rt.MappingHandlerAdapter.run(MappingHandlerAdapter.java:107) at com.sap.aii.ibrep.server.mapping.ServerMapService.transformInterfaceMapping(ServerMapService.java:127) at com.sap.aii.ibrep.server.mapping.ServerMapService.transform(ServerMapService.java:104) at com.sap.aii.ibrep.sbeans.mapping.MapServiceBean.transform(MapServiceBean.java:40) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0_0.transform(MapServiceRemoteObjectImpl0_0.java:167) at com.sap.aii.ibrep.sbeans.mapping.MapServiceRemoteObjectImpl0_0p4_Skel.dispatch(MapServiceRemoteObjectImpl0_0p4_Skel.java:104) at com.sap.engine.services.rmi_p4.DispatchImpl._runInternal(DispatchImpl.java:320) at com.sap.engine.services.rmi_p4.DispatchImpl._run(DispatchImpl.java:198) at com.sap.engine.services.rmi_p4.server.P4SessionProcessor.request(P4SessionProcessor.java:129) at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33) at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41) at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37) at java.security.AccessController.doPrivileged(Native Method) at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100) at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
14:26:31 End of test
Thanks.
-Adrean.
Hi Sridhar,
Just an update that when I add the <!DOCTYPE ... ...> note in the message using the code, it works fine in IM testing untill the IM windows is open in IR. Once I clsoe the window and reopen it starts giving me error "Invalid XML instance" and does not produce any result in IR testing.
More interesting thing is that again it works fine when runtime, means while I am running the full scenario. It doesnt fail there in Interface mapping step.
Strange behavior!!!!
Thanks again though, As the code works fine and my scenario is working now.
-Adrean.
Hey
have a look at the following to delete the namespace
/people/stefan.grube/blog/2007/02/02/remove-namespace-prefix-or-change-xml-encoding-with-the-xmlanonymizerbean
/people/sameer.shadab/blog/2005/12/05/how-to-remove-namespaces-in-mapping--xi
Thanx
Ahmad
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Andrean,
For this to achieve you have to create one UDF and make a search of that name space and replace it with required one....
Then use this UDF with the source message to Target one...(May be the node level ?)
If you know java well then this can be done easily...
If you need details then reply back...
Regards,
sridhar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
24 | |
11 | |
9 | |
7 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.