Sunday, March 24, 2013

Calling external web services

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;