cancel
Showing results for 
Search instead for 
Did you mean: 

Sync Java Proxy Server response in XML

Former Member
0 Kudos

Hi !

We've this scenario: File1 <-> XI <-> Java Proxy <-> File2

Using a BPM, we made a Async/Sync workflow. It works ok. It uses a SYNC Java Proxy Server.

The problem is that inside the java proxy, we query an http source that returns already XML formated data. We need this data to be mapped from the java proxy response message type to the File2 message type.

We know that we can parse the XML data inside the java proxy and fill the response message type structures (creating items, and array items for nested records), or directly code the mapping here.

But, is there any alternative to pass the received XML from the HTTP directly to XI, and map that XML structure with the File2 message type using graphical mapping ? instead of programming the xml parsing and creating the response structure?

If we create a message type for the response of the java proxy, as 1 field that contains the whole XML code, then we would not map it....Is there any way to complete or to add something to the received XML code, to convert it to the XI message format..so XI could interpret it as a true XI message and map it transparently via graphical mapping?

Thanks,

Matias

Accepted Solutions (1)

Accepted Solutions (1)

stefan_grube
Active Contributor
0 Kudos

Hi Mathias,

you can use the messageSpecifier attribut to set the payload directly:

http://help.sap.com/saphelp_nw2004s/helpdata/en/9a/945e3026760745a751a85499139c7c/frameset.htm

messageSpecifier.setPayload(payload)

Hope that helps,

Stefan

Former Member
0 Kudos

Hi Stefan !

Your answer sound very good and easy ! just one more question...if I "charge" the payload using this function...what should I return via the mandatory expected "return" statement of the implementation function? or should I convert the function from type "[myNamespace].DTmyType_Type" to "void" ? I need it to work as a synchronous function....

Thanks !

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Matias.

You can convert the response xml into xsd using a sw like stylus studio and import tht xsd into XI..use it as ur the msg type. This way u can directly send the response from HTTP to XI and then to the file. Try doin it.

Regards,

Akshay

Former Member
0 Kudos

Hi Akshay !

We are using a java proxy to establish the http conection because this is a special http conection not allowed by the default HTTP Adapter (neither the SOAP adapter).

I understand what you say, we have done that, but inside the implementation function of the java proxy (the one in the file terminated in "_PortTypeImpl.java") we should use the "return" java function to return something. We want to "return" the content of the string variable that contains the returned xml formatted data from the http connection.

The question is: how should we return that info FROM the java proxy so we can use the already imported xsd in XI.

Thanks.

Former Member
0 Kudos

Hi Mathias,

I guess the interface from which u created the java proxy must be a synchronous one. It shud be because u hv a return parameter to ur Java proxy. Then u need worry abt the response msg structure. Am i correct?

Regards,

Akshay

Former Member
0 Kudos

Hi Akshay !

That's right ! that's the problem. How can I pass my already xml formatted data contained in a string variable, to XI as a return parameter from java proxy, so XI could map it to another message type via graphical mapping?

Thanks,

Matias.

Former Member
0 Kudos

Hi Mathais,

You need not do much. U hv to capture ur return paramter in the response msg type and send it back. Tht is u hv to fill the response msg type with ur return value and send it across to XI

Regards,

Akshay

Former Member
0 Kudos

Hi Akshay !

That's exactly what I don't know how to do it.

Inside the java proxy function I have a string variable, let's call it xmlResponse, that contains:

<customer>

<name>Matias</name>

<country>China</country>

</customer>

I also have a message type created in XI (let's call it MT_Response), that has the same fields as the above message structure. And my java proxy function is declared something like this:

public MT_Response.Type myFunction(MT_Request.Type myRequest) {

String xmlResponse="";

// http connection code goes here..

xmlResponse = httpConnection.getResponse();

return ??????? what ????

}

I don't want to parse the xmlResponse variable in order to fill the MT_Response structure. I need a more direct way, because the content of xmlResponse is already XML !

Thanks.

Former Member
0 Kudos

Hi Mathias,

I donno the exact code. But wht u can do is create an object of type MT_Response and set this object with the value xmlResponse the one which u get from http. But if they r not compatible, then probably u hv to parse it and then u hv to set it and send it across. I hope this will resolve ur query.

Regards,

Akshay

Former Member
0 Kudos

To achive what you are trying, you need to modify the message type for the message interface from which you generate your Java proxy and have a data type like

<TOP>

<XML_STRUCT></XML_STRUCT>

</TOP>

regenerate the java proxy and then in your impl class set the xml that you recieve using MTResponse.setXML_STRUCT()

Still, you would need to write your parsing logic in the graphical mapping anyways..

Former Member
0 Kudos

Hi Amol !

It sounds good..maybe I can add a XSLT mapping "string to XML" as a second mapping step to solve the parsing....

Thanks.

Matias.