cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping SOAP response to RFC out parameters

Former Member
0 Kudos

Hello

I have RFC to SOAP (sync) scenario.

The SOAP reponse from webservice is an embedded XML string (Result XML wrapped within Response XML; The result string from web service is an XML itself)

How to achieve Message Mapping so that the fields in the result XML can be captured directly in to RFC output paramters?

I have mapped Result XML string to RFC output thru User Defined Function. I have filtered xml tags in UDF but I do not wish to hard code the tags' filtering.

Is there a better solution?

Kindly advise.

cheers

Alkesh

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Could you provide a sample of your message, and maybe an xml sample of your output msg ?

If I get it right, the (XI) XML response contains a string that contains (serialized as an XML string) the XML "business" response ? And you want to build the corresponding RFC input message with some sort of "generic" tag parsing/filtering ?

Do your xml string contains tags in the order expected in the RFC response, so you could use tag number (or position or index, whatever you would name it) instead of names (ie, first tag is the root, 2nd would be the first input param etc) ?

Rgds

Chris

Former Member
0 Kudos

Hey Chris

Here are the structure samples (source & target)

The intention is to map <Elem1> & <Elem2> of each <Line> to RFC structure fields, 'Item1' & 'Item2'.

The <Line> items can be multiple and for each Line one RFC strcuture 'Record' has to be created.

*********source begin**

<?xml version="1.0" encoding="utf-8"?>

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

<soap:Body>

<WSDLResponse xmlns="namespace123">

<WSDLResult>xml_string</WSDLResult>

</WSDLResponse>

</soap:Body>

</soap:Envelope>

...where the xml_string is as below (whole XML)-

<?xml version =''1.0'' encoding=''utf-8'' ?>

<Addr>

<Result>

<ErrorCode>0</ErrorCode>

<ErrorDesc></ErrorDesc>

</Result>

<Return>

<Line>

<Elem1>value1</Elem1>

<Elem2>value2</Elem2>

</Line>

<Line>

<Elem1>value3</Elem1>

<Elem2>value4</Elem2>

</Line>

.

.

.

</Return>

</Addr>

                    • source end***

The target structure is -

                    • target begin***

- RFC strcture

- Record

- Item1

- Item2

                    • source end***

Apologies for the lengthy text but it is quite confusing

What is the best way to achieve mapping?

thx

Alkesh

Former Member
0 Kudos

Dear Alkesh,

First, I have a question regarding how the "xml_string" is embedded within the SOAP response : is it in a CDATA container (because of the XML reserved instruction <?xml version =''1.0'' encoding=''utf-8'' ?> than can not be put as is in a XML structure I think) ?

I'm not sure about how your source is exactly built, before being able to think of a mapping design ... Though I'd do sthg like this :

1 - extract xml_string content and create an InputSource from it

2 - use this InputSource to feed a SAX parser that would then react to the following events :

- <Line> tag encountered : create its corresponding target <Record>

- "startWith("Elem")" tag encountered, create its corresponding target using concat("Item" + part of tagname after "Elem" using substring)

Etc

Rgds

Chris

Former Member
0 Kudos

Dear Chris

I am trying to achieve this using external java mapping program (imported as jar).

Am almost there.

The test in the IR works well.

However, the problem occurs in the runtime. sxmb_moni shows message as successful but Test/Execute RFC in se37 gives SYSTEM FAILURE.

When I chk the moni it shows "The XML page cannot be displayed".

" Invalid at the top level of the document. Error processing resource 'file:///C:/Documents and Settings/xyz...

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><!-- Request Message Mapping --> "

The target structure (RFC response) built in java program is something like this -

output = "
<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns0:FuncModuleName.Response xmlns:ns0=\"urn:sap-com:document:sap:rfc:functions\"><RFC field 1> 2.. 3 ....

Also the communication channel goes RED when I execute RFC in se37 and the error in comm channel monitoring is -

" Error in processing caused by: com.sap.aii.af.rfc.RfcAdapterException: failed to identify XML document:org.xml.sax.SAXParseException: Document root element is missing. "

Any idea what could be the problem?

Mind that it runs well in test mode in IR.

Thx again

Alkesh

Former Member
0 Kudos

Alkesh,

This looks like your target document is malformed, so I suggest downloading the output document from SXMB_MONI as an xml file on your PC and open it with an XML tool that will allow you to identify the mistake

I do not have enough details to identify it myself, but I think you're very close to the end

Rgds

Chris

Former Member
0 Kudos

Dear Chris

The xml itself is blank, exporting to local drive then opening it in browser gives same error. The file content has just xml declaration.

Somehow the rest of the xml contents are not coming thru.

In the 'Inbound Message' Payload under Central I can see the complete xml in the MainDocument.

However, under 'Call Adapter' Payload MainDocument everything except the xml declaration is lost.

So there is a data loss from Central to Adapter Pipeline.

Not sure what could be going wrong.

If you can think of something please advise.

thx!

Alkesh

Answers (1)

Answers (1)

stefan_grube
Active Contributor
0 Kudos

Use XMLAnonymizerBean. This is just designed for this use case.

Regards

Stefan

VijayKonam
Active Contributor
0 Kudos

Stefan,

But as I understand, the requirement is to map the content of one response field (XML element) to the target structure (RFC Response). Is this possible by using this bean?

Just out of curiosity.

VJ

Former Member
0 Kudos

The XMLAnonymizerBean is mainly designed to remove unwanted namespaces and assign prefix to remaining namespaces in the payload and also change its encoding ...

But I'm may be unaware of other purposes

Chris

Edited by: Christophe PFERTZEL on Apr 22, 2008 6:19 PM

stefan_grube
Active Contributor
0 Kudos

Yes, you are right. Sorry, my fault.

Regards

Stefan