Purpose: Configuring OEDQ to invoke external web services, send payloads and publish respons from web services.
Components Needed:
- Custom Script Processor
- Web Service WSDL
- Web Service Endpoint URL
Steps:
1. Add OEDQ Script processor
2. Create script using Goovy to do the following:
a. Try/Catch statement
b. Instantiate new XMLHttpReqest
c. Create xml payload as variable
d. Send xml payload variable
e. Extract value of response tag(s)
f. Publish extracted response tag value(s) as output value
Example Script:
addLibrary("http");
try {
var url = "http://xxxx";
var xmlHttp = new XMLHttpRequest();
var params = "<?xml version='1.0' encoding='UTF-8' ?>" + "<soapenv:Envelope xmlns:v1='http://xxxx'>" + "<soapenv:Body>" + "<RootTag>" + "<Tag1>Iutput1[0]</Tag1>" + "<Tag2>Input1[1]</Tag2>" ...etc + "</RootTag>" + "</soapenv:Body>" + "</soapenv:Envelope>";
var request = params;
var result = new String();
xmlHttp.open("POST", url, false);
xmlHttp.send(request);
request = xmlHttp.responseText;
request = JSON.parse(request);
result = document.getElementById("ResponseTag1").value
}
catch (e) {
result = "Error:";
}
output1 = result;
Hi Jay,
ReplyDeleteI was really excited to see this blog and this is exactly I was looking for.
I tried below piece of code to invoke the external webservice, from within the OEDQ script processor.
#!language: groovy
addLibrary("http")
try {
var url = "http://nacismktl215.us.oracle.com:10777/im-ws/service";
var xmlHttp = new XMLHttpRequest();
var params = "" +
""+
"RamHanRamHan01"+
""+
""+
"Barratts Shoes"+
""+
""+
""+
""+
"United Kingdom"+
""+
"imlookup [public]"+
"Test_mdv [public]"+
"Remote [public]"+
""+
""+
"";
var request = params;
var result = new String();
xmlHttp.open("POST", url, false);
xmlHttp.send(request);
request = xmlHttp.responseText;
request = JSON.parse(request);
result = document.getElementById("ResponseTag1").value
}
catch (e) {
result = "Error:";
}
output1 = result;
After executing, I get this error message:
"Process failed:error in script: Error compiling script: startup failed: Script1.groovy:6 expecting '}', found ':'@Line6, column 31.
"<env:Envelope xmlns:enc="http://schemas.xmlsoap.org/soap/encoding"
Please can you suggest if I am missing anything.
Regards,
Arsalan
Hey Arsalan,
ReplyDeleteGlad this post could help!
It is hard to tell without seeing your full code. My best guess is check your var params. Make sure all restricted characters are encapsulated within quotes. It is also a good practice to review the rest of your code to ensure that no restricted characters are exposed un-intentionally.
Hope this helps.
Hi Jay,
ReplyDeleteVery good article. Thanks for sharing.
Do you have any exposure to EDQ web services consuming business objects (complex XML formats) generated from business evens in Oracle EBS. EDQ web services existing by default are a one to one attribute mapping. I would like to know how can EDQ web services consume a complex XML as an input and hand it back in the same format after processing is done?
Really appreciate if you can throw some light on this issue we are facing.
Thanks.
Regards,
Vardhan
Hi Jay
ReplyDeleteI am having a few issues parsing the XML I am getting back from my custom Script processor in EDQ. I really hope you can offer a few insights into this.
addLibrary("http");
try{
xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "http://usto-dapp-eclna/test.xml", false);
xmlhttp.send(null);
xmlDoc = xmlhttp.responseXML;
xmlStatus = xmlDoc.getElementsByTagName("Status")[0].childNodes[0].nodeValue;
var ScriptResult = new String();
}
catch (e) {
ScriptResult = "Error: " + e.toString();
}
output1 = xmlStatus;
I feel like I have tried a lot of different options and they all work in standard browsers such as Firefox and Chrome. I even tried the following function.
function getNodesAsText(objXML, nodeName)
{
var docElement = objXML.documentElement;
var allNodes = docElement.getElementsByTagName(nodeName);
//Initialize new XMLSerializer
var xmlSer = new XMLSerializer();
var nodesText = "";
// Convert each node into text
for(var i = 0; i < allNodes.length; i++)
{
nodesText += xmlSer.serializeToString(allNodes[i]);
}
return nodesText;
}
xmlStatus = getNodesAsText(xmlDoc,"Status");
Hope you can help out.
Cheers
-J