cancel
Showing results for 
Search instead for 
Did you mean: 

UDF required !! Cannot create target element Values missing in queue context

Former Member
0 Kudos

Dear Experts,

I am getting the cannot create target element error with acknowledgement payload in response message mapping  in synchronous interface. I have shared the response payload2. Please suggest do I need write any UDF.

Message mapping successful with below payload1:

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

<ns0:updateOppResponse xmlns:ns0="http://soap.sforce.com/schemas/class/clientUpdateInqWebService">

   <ns0:result>

      <ns0:Description>Record Updated</ns0:Description>

      <ns0:SFDCId>006M0000007xjTrIAI</ns0:SFDCId>

      <ns0:Status>true</ns0:Status>

   </ns0:result>

</ns0:updateOppResponse>

With the below target system response message, Mapping failing with Cannot create target element /ns1:MT_InquiryUpdate_ECC_Ack. Values missing in queue context. Target XSD requires a value for this element, but the target-field mapping does not create one. Check whether the XML instance is valid for the source XSD, and whether the target-field mapping fulfils the requirement of the target XSD com.sap.aii.mappingtool.tf7.IllegalInstanceException:

Actual acknowledgement reply from target system payload2:

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

<soapenv:Envelope xmlns="http://soap.sforce.com/schemas/class/clientUpdateInqWebService" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">

   <soapenv:Body>

      <updateOppResponse>

         <result>

            <Description>Record Updated</Description>

            <SFDCId>006M0000007xjTrIAI</SFDCId>

            <Status>true</Status>

         </result>

      </updateOppResponse>

   </soapenv:Body>

</soapenv:Envelope>

Regards

RKN

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi


The easiest solution will be , write an simple java map for your response mapping.

Please provide your target structure , if you need any help on the java mapping.

Sample code:

Response message from web service

target msg:

java code:

package com.sap;

import javax.xml.parsers.DocumentBuilder;

import javax.xml.parsers.DocumentBuilderFactory;

import javax.xml.transform.Result;

import javax.xml.transform.Source;

import javax.xml.transform.Transformer;

import javax.xml.transform.TransformerFactory;

import javax.xml.transform.dom.DOMSource;

import javax.xml.transform.stream.StreamResult;

import org.w3c.dom.Document;

import org.w3c.dom.Element;

import org.w3c.dom.Node;

import org.w3c.dom.NodeList;

import com.sap.aii.mapping.api.AbstractTransformation;

import com.sap.aii.mapping.api.StreamTransformationException;

import com.sap.aii.mapping.api.TransformationInput;

import com.sap.aii.mapping.api.TransformationOutput;

public class populateResponseMessage extends AbstractTransformation {

      public void transform(TransformationInput arg0, TransformationOutput arg1)

                  throws StreamTransformationException {

            try {

                  DocumentBuilderFactory tfactory = DocumentBuilderFactory

                              .newInstance();

                  DocumentBuilder tbuilder = tfactory.newDocumentBuilder();

                  Document doc = tbuilder.parse(arg0.getInputPayload()

                              .getInputStream());

                  Document newdoc = tbuilder.newDocument();

                  Element root = (Element) newdoc.createElementNS(

                              "urn:sap-com:document:sap:rfc:functions",

                              "ns1:ZTEST_FAULT_MESSAGE_DATA.Response");

                  newdoc.appendChild(root);

                  NodeList nlList = doc.getElementsByTagName("ConversionRateResult");

                  if (nlList.getLength() != 0 && nlList != null) {

                        Node data = nlList.item(0);

                        String sourceval = data.getTextContent();

                        Element rate = (Element) newdoc.createElement("RATE");

                        rate.setTextContent(sourceval);

                        root.appendChild(rate);

                      

                      

                  }

                

                  Transformer transformer = TransformerFactory.newInstance()

                              .newTransformer();

                  Source source = new DOMSource(newdoc);

                  Result output = new StreamResult(arg1.getOutputPayload().getOutputStream());

                  transformer.transform(source, output);

            } catch (Exception e) {

                  e.printStackTrace();

            }

      }// end of transform

}

Former Member
0 Kudos

Hi Indrajit,

Thank you for your inputs.

I have used the Java mapping and while mapping testing getting the below error. Do I need to make any changes in the code !!.

Unable to display tree view; Error when parsing an XML document (Premature end of file.)   Runtime Exception when executing application mapping programcom/sap/xi/tf/_MessageMapping_Response_; Details:com.sap.aii.utilxi.misc.api.BaseRuntimeException; Premature end of file.

See error logs for details

Java Code:

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.InputStream;

import java.io.OutputStream;

import java.util.Map;

import javax.xml.parsers.DocumentBuilder;

import javax.xml.parsers.DocumentBuilderFactory;

import javax.xml.transform.Transformer;

import javax.xml.transform.TransformerFactory;

import javax.xml.transform.dom.DOMSource;

import javax.xml.transform.stream.StreamResult;

import org.w3c.dom.Document;

import org.w3c.dom.Element;

import org.w3c.dom.Node;

import org.w3c.dom.NodeList;

import com.sap.aii.mapping.api.StreamTransformation;

import com.sap.aii.mapping.api.StreamTransformationException;

public class RemoveSoapEnvelope implements StreamTransformation {

    public void execute(InputStream in, OutputStream out)

    throws StreamTransformationException {

  try

    {

         DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();

         DocumentBuilder builderel=factory.newDocumentBuilder();

       

  /*input document in form of XML*/

        

  Document docIn=builderel.parse(in);

        

  /*document after parsing*/

       

  Document docOut=builderel.newDocument();

         TransformerFactory tf=TransformerFactory.newInstance();

         Transformer transform=tf.newTransformer();

         Element root;

         Node p;

  NodeList l;

         int mm,n1;

         //if you need to include namespace use next two lines

         root=docOut.createElement("ns0:updateOppResponse");

         root.setAttribute("xmlns:ns0","http://soap.sforce.com/schemas/class/ClientUpdateInqWebService");

         root=docOut.createElement("updateOppResponse");

         p=docIn.getElementsByTagName("updateOppResponse").item(0);

         l=p.getChildNodes();

         n1=l.getLength();

         for(mm=0;mm<n1;++mm)

         {

              Node temp=docOut.importNode(l.item(mm),true);

              root.appendChild(temp);

         }   

         docOut.appendChild(root);

         transform.transform(new DOMSource(docOut), new StreamResult(out));

    }

    catch(Exception e)

    {

         e.printStackTrace();

    }

    }

    

    public void setParameter(Map arg0) {

    }

    public static void main(String[] args) throws Exception

    {

    try{

        RemoveSoapEnvelope genFormat=new RemoveSoapEnvelope();

         FileInputStream in=new FileInputStream("/D:/input.xml");

         FileOutputStream out=new FileOutputStream("/D:/Output.xml");

         genFormat.execute(in,out);

    }

    catch(Exception e)

    {

    e.printStackTrace();

    }

    }

  

}

Former Member
0 Kudos

Hi

Go to operation mapping, and choose the java mapping as response mapping.

I can see that you are still using Message Mapping as response mapping in operation mapping.

Former Member
0 Kudos

Hi Indrajit,

Thank you for your inputs..now the interface is working.

But the response message is not updating the ECC tables in ABAP proxy code. While debugging the ABAP client proxy(se38) the response message is successfully receiving at ECC Moni level but not getting the same at code level to update the SE11 tables.

Response payload at source System ECC Moni level.

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>

- <ns1:InquiryUpdate_Ack xmlns:ns1="http://client.in/CreateAndChangeInquiryUpdate">

- <record>

<SFA_RefID>006M0000007777777</SFA_RefID>

<SFA_Acknowledgement>true</SFA_Acknowledgement>

<ERROR_Description>Record Updated</ERROR_Description>

</record>

  </ns1:MT_InquiryUpdate_ECC_Ack>    

    

     Please suggest.

    

     Regards

     RK








Former Member
0 Kudos

Hi

Take the xml payload for the response message, then goes to ECC system, execute transaction sproxy.

Test the proxy class with the input xml and see why the tables are not updated in SE11?

Former Member
0 Kudos

Hello Indrajit,

The below are the response payloads during the ABAP proxy testing.

Original Response payload (with Java mapping):

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>

- <ns1:MT_InquiryUpdate xmlns:ns1="http://Client.in/CreateAndChangeInquiryUpdate">

- <record>

<SFA_RefID>006M0000007xjTrIAI</SFA_RefID>

<SFA_Acknowledgement>true</SFA_Acknowledgement>

<ERROR_Description>Record Updated</ERROR_Description>

</record>

</ns1:MT_InquiryUpdate>

    

     Response payload:


- <nm:MT_InquiryUpdate xmlns:nm="http://client.in/CreateAndChangeInquiryUpdate" xmlns:prx="urn:sap.com:proxy:TCD:/1SAI/TAS44216CB7E490486F0A12:740">

- <record>

<SFA_RefID>006M0000007xjTrIAI</SFA_RefID>

<SFA_Acknowledgement>true</SFA_Acknowledgement>

<ERROR_Description>Record Updated</ERROR_Description>

</record>

</nm:MT_InquiryUpdate>.


Please suggest.


Regards

RK





Former Member
0 Kudos

Hi

Please open a new thread and provide me the exact error you are facing. If possible provide the screen shot of the problem so that I can help u better.

Close this thread.

Answers (2)

Answers (2)

markangelo_dihiansan
Active Contributor
0 Kudos

Hi,

It looks like you are running in No SOAP mode and adding to what Sunil said, the successful payload has a namespace prefix while the one actually sent does not have. In the intermediate mapping, add a logic that adds/removes the namespace prefixes as well.

Regards,

Mark

sunilchandra007
Active Contributor
0 Kudos

It seems you are trying to map some web service response to your message type. The soap envelope in the the response is not matching to your message type. You need an intermediate mapping to remove soapenv:Envelope and soapenv:Body before your main mapping.

Regards,

Sunil Chandra