cancel
Showing results for 
Search instead for 
Did you mean: 

CDATA Error - While Parsing RFC Lookup Response

former_member185846
Active Participant
0 Kudos

Hi All,

I'm doing a simple RFC Lookup (using RFC Lookup API) from XI to ECC. But the RFC response XML (from ECC to XI) contains CDATA (as below); hence my lookup is failing to parse it. I'm not sure why this is happening. Please suggest the ways to reslove it.

<![CDATA[<?xml version="1.0" encoding="UTF-8"?><rfc:ZSCE_RFC_LOOKUP.Response xmlns:rfc="urn:sap-com:document:sap:rfc:functions"><RESULT1>2</RESULT1><RESULT2>1.000-</RESULT2></rfc:ZSCE_RFC_LOOKUP.Response>]]>

Thanks,

Joe.

Accepted Solutions (1)

Accepted Solutions (1)

Shabarish_Nair
Active Contributor
0 Kudos
former_member185846
Active Participant
0 Kudos

Hi Shabarish,

Thanks for your prompt reply. I've already checked with that. However, below is my code for your reference.

MappingTrace trace;

trace = container.getTrace();

String m = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +

"<ns0:ZSCE_RFC_LOOKUP" +

" xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\"><TANUM>" + a +

"</TANUM><VSOLA>" + b +

"</VSOLA></ns0:ZSCE_RFC_LOOKUP>" ;

RfcAccessor accessor = null;

ByteArrayOutputStream out = null;

InputStream in = null;

try

{

Channel channel = LookupService.getChannel("BS_RFC_Lookup","CC_RFC_RCVR");

accessor = LookupService.getRfcAccessor(channel);

InputStream inputStream = new ByteArrayInputStream(m.getBytes());

XmlPayload payload = LookupService.getXmlPayload(inputStream);

Payload result = accessor.call(payload);

in = result.getContent();

}catch(LookupException e)

{

trace.addWarning("Error while lookup " + e.getMessage() );

}

String txt = "";

InputStreamReader inR = new InputStreamReader(in);

BufferedReader buf = new BufferedReader(inR);

String line;

while ( ( line = buf.readLine() ) != null )

{

txt = txt + line;

}

/*

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

DocumentBuilder builder = null;

factory.setNamespaceAware(false);

factory.setValidating(false);

Document docRsp = null;

try {

docRsp = builder.parse(in);

} catch (Exception e) {

trace.addWarning("Error when parsing RFC Response1 - " + e.getMessage()); return null;

} */

//trace.addInfo("RFC Response XML: " + docRsp.toString());

if (accessor!=null) {

try {

accessor.close();

} catch (LookupException e) {

trace.addWarning("Error while closing accessor " + e.getMessage() );

}

}

return txt;

Thanks,

Joe.

former_member190389
Active Contributor
0 Kudos

Hi,

I have a java mapping which requires Source Interface to be RFC request & target will be ur RFC response.Do not forget to change the Business System and Commuication channel.

Check this out.

http://knowhowsapxi.synthasite.com/rfc-loolup.php

just compile it and import it into imported archives then use it in the interface mapping.

You can have multi step mappings like firststep Msg Mapping to convert src to RFC Request format second step as the Java mapping of RFC Lookup and 3rd step again to convert RFC response to target message using a msg mapping.

Answers (1)

Answers (1)

former_member190389
Active Contributor
0 Kudos

Any Ways I think the error is that you are using < ( sign) instead of & l t ; same for > & other chars