cancel
Showing results for 
Search instead for 
Did you mean: 

Response message mapping error

Former Member
0 Kudos

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.



Accepted Solutions (1)

Accepted Solutions (1)

former_member186851
Active Contributor
0 Kudos

Nick,

If possible get the WSDL from the webservice.

Former Member
0 Kudos

Hi Raghuraman,

How would getting a WSDL from the webservice help me ?

Is there any way I can download the WSDL from the webservice directly ?

Answers (1)

Answers (1)

markangelo_dihiansan
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Hi Mark,

Can you please provide a sample XSLT or Java mapping code using which this can be achieved .

Thank you .

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Nick,

Can you provide the xml output of the rest adapter and the message type in your message mapping?

Regards,

Mark

Former Member
0 Kudos

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 .

markangelo_dihiansan
Active Contributor
0 Kudos

Hi,

How does your target message type look like?

Regards,

Mark

Former Member
0 Kudos

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>

markangelo_dihiansan
Active Contributor
0 Kudos

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