Invoking an External Web Service Using Workflow or Scripting
As illustrated in the following figure, the following steps are executed to call an external Web service:
-
The developer obtains the Web service description as a WSDL file.
-
The WSDL Import Wizard is called.
-
The WSDL Import Wizard generates definitions for outbound proxy, integration objects for complex parts, and administration entries.
-
The Outbound Web Service proxy is called with the request property set.
-
The request is converted to an outbound SOAP request and sent to the external application.
-
The external application returns a SOAP response.
-
The SOAP response is converted to a property set that can be processed by the caller, for example, Calling Function.
- The following example shows how to invoke Web services using Siebel eScript:
function Service_PreCanInvokeMethod (MethodName, &CanInvoke) { if (MethodName == "invoke") { CanInvoke = "TRUE"; return (CancelOperation); } else return (ContinueOperation); } function Service_PreInvokeMethod (MethodName, Inputs, Outputs) { if (MethodName == "invoke") { var svc = TheApplication().GetService("CustomerDBClientSimpleSoap"); var wsInput = TheApplication().NewPropertySet(); var wsOutput = TheApplication().NewPropertySet(); var getCustInput = TheApplication().NewPropertySet(); var listOfGetCustomerName = TheApplication().NewPropertySet(); var getCustomerName = TheApplication().NewPropertySet(); try { // obtain the customer ID to query on. This value will be provided in the input property set var custId = Inputs.GetProperty("custId"); // set property to query for a customer ID with a value of '1' getCustomerName.SetType("getCustomerName"); getCustomerName.SetProperty("custid", custId); // set Type for listOfGetCustomerName listOfGetCustomerName.SetType("ListOfgetCustomerName"); // set Type for getCustInput getCustInput.SetType("getCustomerNameSoapIn:parameters"); // assemble input property set for the service. listOfGetCustomerName.AddChild(getCustomerName); getCustInput.AddChild(listOfGetCustomerName); wsInput.AddChild(getCustInput); invoke the getCustomerName operation svc.InvokeMethod("getCustomerName", wsInput, wsOutput); // parse the output to obtain the customer full name check the type element on each PropertySet (parent/child) to make sure we are at the element to obtain the customer name if (wsOutput.GetChildCount() > 0) { var getCustOutput = wsOutput.GetChild(0); if (getCustOutput.GetType() == "getCustomerNameSoapOut:parameters") { if (getCustOutput.GetChildCount() > 0) { var outputListOfNames = getCustOutput.GetChild(0); if (outputListOfNames.GetType() == "ListOfgetCustomerNameResponse") { if (outputListOfNames.GetChildCount() > 0) { var outputCustName = outputListOfNames.GetChild(0); if (outputCustName.GetType() == "getCustomerNameResponse") { var custName = outputCustName.GetProperty("getCustomerNameResult"); Outputs.SetProperty("customerName", custName); } } } } } } return (CancelOperation); } catch (e) { TheApplication().RaiseErrorText(e); return (CancelOperation); } } else return (ContinueOperation); }