on 09-22-2005 2:50 PM
Hi everyone
I am using RFC to send XML data from CRM to XI.
My function modules (/MARS/CPE_IMPORT_CRM_CATALOG) contains only one parameter (IV_CATALOG) declared as a string so all XML data is put in this string.
If I try sending the following string from CRM:
<TEST>GREG</TEST>
The payload on XI looks like this:
<xml version="1.0" encoding="UTF-8"?>
<rfc:_-MARS_-CPE_IMPORT_CRM_CATALOG xmlns:rfc="urn:sap-com:document:sap:rfc:functions">
<IV_CATALOG><TEST>GREG</TEST></IV_CATALOG></rfc:_-MARS_-CPE_IMPORT_CRM_CATALOG>
As you can see < is converted into < and > into >
Where and how do I specify that the content of the parameter must not be interpreted?
Thanks
Greg
We found out that The RFC adapter serializes the content of the paramters (for instance the characters < and >) in order to avoid conflicts with real XML tags. Else you could easily create non valid XML.
Here is the workaround:
Add the following mapping between the adapter and your real mapping. This mapping simply converts the < resp. > into < resp. >. It is then possible to send XML into the RFC parameters. Be carefull as if the XML sent in the parameter is no well formed, the message will be rejected by XI.
package com.sap.mymappings;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.Map;
import com.sap.aii.mapping.api.StreamTransformation;
public class DecodeXml implements StreamTransformation {
private Map map;
private OutputStream out;
/**
*/
public DecodeXml() {
super();
// Auto-generated constructor stub
}
/**
method setParamters is required, but we do not anything with it
*/
public void setParameter(Map param) {
map = param;
}
/**
method execute is called by the XI mapping program
*/
public void execute(InputStream in, OutputStream out)
throws com.sap.aii.mapping.api.StreamTransformationException {
InputStreamReader inReader = new InputStreamReader(in);
// 2. Helper classes to read in data
BufferedReader bufReader = new BufferedReader(inReader);
String s;
String helpString = new String();
String resString = new String();
int i = 0;
try {
while ((s = bufReader.readLine()) != null) {
helpString = s.replaceAll("<", "<");
helpString = helpString.replaceAll(">", ">");
resString = resString + helpString;
i++;
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
bufReader.close();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
// 4. Write data to OutputStream
byte[] resByte = resString.getBytes();
try {
out.write(resByte, 0, resByte.length);
} catch (IOException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gregory,
everything is working allright. If ur '<' would not have been transcripted, ur XML at XI would not be wellformed :(.
Regards,
Udo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Udo
I don't understand why it wouldn't be wellformed...
<xml version="1.0" encoding="UTF-8"?>
<rfc:_-MARS_-CPE_IMPORT_CRM_CATALOG xmlns:rfc="urn:sap-com:document:sap:rfc:functions">
<IV_CATALOG><TEST>GREG</TEST></IV_CATALOG></rfc:_-MARS_-CPE_IMPORT_CRM_CATALOG>
is a valid XML.
Morevover I can see on a post from Dirk Meinhard called "Imported RFC with problem in converting to XML" that he was able to send the following data via RFC:
<?xml version="1.0" encoding="UTF-8" ?>
- <rfc:Z_BI_SEND_DATA_512 xmlns:rfc="urn:sap-com:document:sap:rfc:functions">
<SYSID_HOME>AAA</SYSID_HOME>
<TARGETSYS>BBB</TARGETSYS>
- <DATA>
- <item>
<WA>test1</WA>
</item>
- <item>
<WA>test2</WA>
</item>
- <item>
<WA>test3</WA>
</item>
</DATA>
</rfc:Z_BI_SEND_DATA_512>
So I assume what I aim to do is possible!
Any idea?
Thanks!
Greg
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.