on 02-09-2013 6:36 AM
Dear SDNer's
We need to invoke a web service from PI 7.31 whose elements are slightly typical as compared to normal web service. The elements are like this
<data xsi:type="xsd:string"> Hello </data>
and this <data xsi:type="xsd:string"> is not an attribute, its an element. What PI would normally generate is <data> Hello </data>
We have tried achieving this with Java Mapping, but we get a parsing exception. Actually withing this data tag we need to pass some data in xml format. How to generate these xsi:type ="xsd:string" ?
Any other way to deal with this?
Regards
Monika
Hello Monika,
<data xsi:type="xsd:string"> Hello </data>
and this <data xsi:type="xsd:string"> is not an attribute, its an element. What PI would normally generate is <data> Hello </data>
We have tried achieving this with Java Mapping, but we get a parsing exception.
The webservice that you are connecting to is using rpc-style instead of the more common document-literal which our native SOAP Adapter supports. According to SAP Note 856597 Q. 9 Does the RPC or Document style in WSDL play a role in the SOAP adapter?
A: No. These styles are used in WSDL to describe how the message is
represented as a SOAP message. And this corresponds to how the XI
payload is represented. You must make sure that your XI proxy is
generating the valid payload according to the given WSDL in
whatever the style. If this is not the case (e.g., your proxy is
generated by another WSDL and there is a mismatch in how the
payload must look), you need to configure some mapping to match the
payload.
So your java mapping approach is correct. Can you tell us what is the error that you are getting and if you can share your code?
Regards,
Mark
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mark,
The Java mapping code is as follows
import java.io.*;
import com.sap.aii.mapping.api.*;
public class GenerateXSI extends AbstractTransformation {
public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput) throws StreamTransformationException {
try{
InputStream inputstream = transformationInput.getInputPayload().getInputStream();
OutputStream outputstream = transformationOutput.getOutputPayload().getOutputStream();
byte[] b = new byte[inputstream.available()];
inputstream.read(b);
String strinputcontent = new String(b);
String stroutputcontent = getXMLOutput(strinputcontent);
outputstream.write(stroutputcontent.getBytes());
} catch (Exception exception) { exception.printStackTrace(); }
} //End of Transform Method.
public static String getXMLOutput(String ss) {
StringBuffer outsb = new StringBuffer();
outsb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
outsb.append("<in0 soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xsi:type=\"q1:LOSRequest\">");
outsb.append("<data xsi:type=\"xsd:string\">");
outsb.append("<![CDATA[");
outsb.append(ss.substring(ss.indexOf("<SettlementSuccessRequest>"),ss.indexOf("</SettlementSuccessRequest>")));
outsb.append("</SettlementSuccessRequest>");
outsb.append("]]");
outsb.append("</data>");
outsb.append("<requestid xsi:type=\"xsd:string\"></requestid>");
outsb.append("<userCtx xsi:type=\"to:LOSUserContext\" xmlns:to=\"http://to.service.los\">");
outsb.append("<password xsi:type=\"xsd:string\"></password><userId xsi:type=\"xsd:string\"></userId>");
outsb.append("</userCtx>");
outsb.append("</in0>");
return outsb.toString();
} //End of getXMLOutput Method
}
we are able to generate the target XML but is during the runtime that there is no payload that is send to target server.
Also while testing the Operation mapping we get the following error
Unable to display tree view; Error when parsing an XML document (The prefix "soapenv" for attribute "soapenv:encodingStyle" associated with an element type "in0" is not bound.)
Regards
Monika
Hello Monika,
Couple of comments:
outsb.append("<in0 soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" xsi:type=\"q1:LOSRequest\">");
Since you are not building a soap envelope, you need to append
<in0 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> instead
outsb.append("<![CDATA[");
outsb.append(ss.substring(ss.indexOf("<SettlementSuccessRequest>"),ss.indexOf("</SettlementSuccessRequest>")));
outsb.append("</SettlementSuccessRequest>");
outsb.append("]]");
outsb.append("</data>");
CDATA is terminated incorrectly, should be ]]>
You can use this as sample xml:
<?xml version="1.0" encoding="UTF-8"?>
<in0 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<data xsi:type="xsd:string"><![CDATA[<SettlementSuccessRequest></SettlementSuccessRequest;]]>
</data>
<requestid xsi:type="xsd:string"></requestid>
<userCtx xsi:type="to:LOSUserContext" xmlns:to="http://to.service.los">
<password xsi:type="xsd:string"></password>
<userId xsi:type="xsd:string"></userId>
</userCtx>
</in0>
If you need it wrapped in a SOAP Envelope, just follow this example:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="urn:ngaMobilityWidgetlogwsdl">
<soapenv:Header/>
<soapenv:Body>
<in0 soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<data xsi:type="xsd:string"><![CDATA[<SettlementSuccessRequest></SettlementSuccessRequest;]]>
</data>
<requestid xsi:type="xsd:string"></requestid>
<userCtx xsi:type="to:LOSUserContext" xmlns:to="http://to.service.los">
<password xsi:type="xsd:string"></password>
<userId xsi:type="xsd:string"></userId>
</userCtx>
</in0>
</soapenv:Body>
</soapenv:Envelope>
Hope this helps,
Mark
Hi Monika,
We had an issue recently with some XML parsing issues where a third party application was sending tags the attribute xsi:nil="true" defined. The one issue was that the namespace was getting stripped from the message. One thing to check would be to make sure the namespace declaration for xsi is made within your java mapping.
Regards,
Ryan Crosby
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
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.