Imports
-
<!--
-
<import location="oracle.xml.parser.v2.XMLElement" importType="http://schemas.oracle.com/bpel/extension/java"/>
-
<import location="ic.ac.uk.ic.utils.json_to_xml.ICJson_Converter" importType="http://schemas.oracle.com/bpel/extension/java"/>
-
-->
-
-
<!--
-
<import location="ic.ac.uk.ic.utils.json_to_xml.XML" importType="http://schemas.oracle.com/bpel/extension/java"/>
-
<import location="ic.ac.uk.ic.utils.json_to_xml.JSONObject" importType="http://schemas.oracle.com/bpel/extension/java"/>
-
-
<import location="org.xml.sax.InputSource" importType="http://schemas.oracle.com/bpel/extension/java"/>
-
<import location="java.io.StringReader" importType="http://schemas.oracle.com/bpel/extension/java"/>
-
<import location="org.w3c.dom.Document" importType="http://schemas.oracle.com/bpel/extension/java"/>
-
<import location="javax.xml.parsers.DocumentBuilderFactory" importType="http://schemas.oracle.com/bpel/extension/java"/>
-
<import location="javax.xml.parsers.DocumentBuilder" importType="http://schemas.oracle.com/bpel/extension/java"/>
-
-->
-
<extensionActivity>
-
<bpelx:exec name="Java_Embedding1" language="java">
-
<![CDATA[XMLElement srcElem = (XMLElement) getVariableData("inputVariable", "part1", "/ns1:RequestMessage/ns1:InputMsg");
-
-
-
-
String JSONstr = "";
-
JSONstr = srcElem.getTextContent();
-
/*
-
JSONObject json = new JSONObject(JSONstr);
-
String xmlF = XML.toString(json); */
-
-
String xml = "DS";
-
// String xml = "<xml xmlns=\"TESTNAMESPACE\">" + ICJson_Converter.toXML(JSONstr) + "</xml>";
-
-
setVariableData("outputVariable","part1","ns1:ResponseMsg","JSON was: " + JSONstr);
-
-
//setVariableData("outputVariable","part1","ns1:GeneratedXML",xml);
-
setVariableData("XMLString",xml);]]>
-
</bpelx:exec>
-
</extensionActivity>
Getting a string
Put import after process tag:
-
<import location="oracle.xml.parser.v2.XMLElement" importType="http://schemas.oracle.com/bpel/extension/java"/>
-
<extensionActivity>
-
<bpelx:exec name="Java_CallRestfulService" language="java">
-
<![CDATA[
-
-
-
String response = "";
-
-
XMLElement uriE = (XMLElement) getVariableData("inputVariable","part1","/ns2:requestMessage/ns2:URI");
-
String uri = uriE.getTextContent();
-
-
response = "Test:" + uri;
-
} catch (Exception e) {
-
response = "ERROR:" + e.getMessage();
-
}
-
setVariableData("JSON_Response", response);]]>
-
</bpelx:exec>
-
</extensionActivity>
Good Error Practice
-
<import location="oracle.xml.parser.v2.XMLElement" importType="http://schemas.oracle.com/bpel/extension/java"/>
-
<import location="javax.xml.namespace.QName" importType="http://schemas.oracle.com/bpel/extension/java"/>
-
<import location="com.oracle.bpel.client.BPELFault" importType="http://schemas.oracle.com/bpel/extension/java"/>
-
try {
-
-
XMLElement responseEle = (XMLElement) getVariableData("outputVariable","response","/ns1:RequestResponse");
-
-
XMLElement StatusEle = new XMLElement("Status", "", ns);
-
StatusEle.addText("OK");
-
responseEle.appendChild(StatusEle);
-
-
-
BPELFault bpelFault = new BPELFault(qName);
-
bpelFault.setPart("code", "JAVAEMBEDDING");
-
bpelFault.setPart("summary", e.getClass().getName() + ": " + e.getMessage());
-
bpelFault.setPart("detail", e.getMessage());
-
// throw the fault
-
throw bpelFault;
-
}
Simple String
Remember to CAST
-
String ClientID = (String) getVariableData("ClientID");
-
-
ClientID = "SSS";
-
-
setVariableData("ClientID",ClientID);
Read String value that could be null
-
XMLElement srcBatchID = null;
-
String batchID = "";
-
try {
-
srcBatchID = (XMLElement) getVariableData("inputVariable", "part1", "/ns2:Message/ns2:header/ns3:BatchID");
-
batchID = srcBatchID.getTextContent();
-
} catch (BPELFault bpfe) {
-
QName qName = new QName("http://docs.oasis-open.org/wsbpel/2.0/process/executable", "selectionFailure");
-
if (!qName.equals(bpfe.getFaultName())) {
-
throw bpfe;
-
}
-
srcBatchID = null;
-
batchID = "";
-
};
RJM Article Type
Work Notes