on 11-03-2015 4:22 AM
Hi Experts ,
I have a Proxy to REST synchronous scenario. During response mapping I am getting the error
Runtime exception occurred during application mapping com/sap/xi/tf/_SAP_Events_MM_; com.sap.aii.mappingtool.tf7.IllegalInstanceException: Cannot create target element /ns0:MT_response/return. Values missing in queue context.
When I run the test from Advanced REST Client the output comes likes below structure.
<ns2:return>
<status> </status>
<ns2:events>
<ns2:event>
</ns2:event>
</ns2:events>
<ns2:link>
</ns2:return>
How can I map this in output to my message response in the mapping . Data type does not seem to be accepting the value of "ns2:"
Please provide your valuable inputs.
Nick,
If possible get the WSDL from the webservice.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nick,
I see that your REST is now working. For your requirement, you can use XSLT or Java mapping to adjust to the correct structure.
Regards,
Mark
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I have subsituted the business data with #
Below is the rest response
<?xml version="1.0" encoding="UTF-8"?>
<ns2:return xmlns:ns2="http://schemas.#/dap" xmlns:ns3="http://schemas.#">
<status>1 to 2 of 113 </status>
<ns2:events>
<ns2:event>
<id>1234</id>
<eventLabel>1111</eventLabel>
<status>Active</status>
<ns2:link method="GET" rel="self" uri="https://#/events/#?apikey=#&eventType=Activation"/>
<ns2:link method="GET" rel="retrieveEventMessages" uri="https://#/messages?label=1111"/>
</ns2:event>
<ns2:event>
<id>9876</id>
<eventLabel>2222</eventLabel>
<status>Active</status>
<ns2:link method="GET" rel="self" uri="https://#/events/#?apikey=#&eventType=Activation"/>
<ns2:link method="GET" rel="retrieveEventMessages" uri="https://#/messages?label=2222"/>
</ns2:event>
</ns2:events>
<ns2:link method="GET" rel="next" uri="https://#/events/?apikey=#&eventType=Activation&offset=20&limit=20"/>
</ns2:return>
I require only the events data and dont require other data.
<events>
<event>
<id>1234</id>
<eventLabel>1111</eventLabel>
<status>Active</status>
<event>
<event>
<id>9876</id>
<eventLabel>2222</eventLabel>
<status>Active</status>
<event>
<events>
Please suggest how I can map the response back and the corresponding XLST or Java mapping that can be used .
Hi Mark,,
As I only need events data , my target message type will be the same structure as the one I am looking to capture.
<events>
<event>
<id>1234</id>
<eventLabel>1111</eventLabel>
<status>Active</status>
<event>
<event>
<id>9876</id>
<eventLabel>2222</eventLabel>
<status>Active</status>
<event>
<events>
Hi Nick,
Here is a very short java mapping example that will extract the events.
package ia_test;
import java.io.InputStream;
import org.apache.commons.io.IOUtils;
import com.sap.aii.mapping.api.AbstractTransformation;
import com.sap.aii.mapping.api.TransformationInput;
import com.sap.aii.mapping.api.TransformationOutput;
public class ExtractEvent extends AbstractTransformation{
private static StringBuffer data = new StringBuffer("");
private static int str=0,end=0;
public void transform(TransformationInput input, TransformationOutput output){
try{
InputStream is = input.getInputPayload().getInputStream();
data.append(IOUtils.toString(is));
is.close();
str = data.indexOf("<ns2:events>");
end = data.lastIndexOf("</ns2:events>");
data = new StringBuffer(data.substring(str,end+13).replaceAll("ns2:", ""));
output.getOutputPayload().getOutputStream().write(data.toString().getBytes());
}
catch(Exception e){
e.getMessage();
}
}}
ps: You will need to import the jar file commons-io.2.4.jar (Apache library). For some reason, I am unable to find the
SAP provided IOUtils in PI 7.4.
Regards,
Mark
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.