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:

  1. The developer obtains the Web service description as a WSDL file.

  2. The WSDL Import Wizard is called.

  3. The WSDL Import Wizard generates definitions for outbound proxy, integration objects for complex parts, and administration entries.

  4. The Outbound Web Service proxy is called with the request property set.

  5. The request is converted to an outbound SOAP request and sent to the external application.

  6. The external application returns a SOAP response.

  7. The SOAP response is converted to a property set that can be processed by the caller, for example, Calling Function.

    Invoking an External Web Service. This image is described in surrounding text.
  8. 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);
    }