on 03-19-2014 6:23 AM
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
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
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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();
}
}
}
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" ?>
</record>
</ns1:MT_InquiryUpdate_ECC_Ack>
Please suggest.
Regards
RK
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" ?>
</record>
</ns1:MT_InquiryUpdate>
Response payload:
</record>
</nm:MT_InquiryUpdate>.
Please suggest.
Regards
RK
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.