Integration Platform Technologies: Siebel eBusiness Application Integration Volume ll > Web Services >

Examples of Invoking Web Services


The following two examples show sample flows of how to invoke an external Web Service from a Siebel application or how to invoke a Siebel Web Service from an external application.

Invoking an External Web Service Using Workflow or Scripting

As illustrated on Figure 26, the following steps are executed to invoke an external Web Service.

  1. The developer obtains Web Service description as a WSDL file.
  2. The WSDL Import Wizard is invoked.
  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 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.
    Figure 26.  Invoking an External Web Service
    Click for full size image

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);

}

About Invoking a Siebel Web Service From an External Application

As illustrated in Figure 27, the following steps are executed to invoke a Siebel Web Service from an external application.

  1. The WSDL document for an active Web Service is published in Siebel Inbound Web Services screen. To allow processing of the Web Service requests, the developer has to make sure:
    1. The Web Server and the Siebel Server are up and running.
    2. The appropriate setup is done in the Siebel Server.
  2. In the external application, the WSDL document is imported in order to create a proxy that can be used to call the Siebel Web Service from Step 1.
  3. The external application sends the SOAP request into the Siebel application.
  4. The Web Service Inbound Dispatcher converts the SOAP request to a property set. Depending on the inbound Web Service configuration, the property set is passed to a business service or a business process.
  5. The property set gets returned from the business service or business process to the Web Service Inbound Dispatcher.
  6. Response is converted to a SOAP message and sent back to the calling external application.
    Figure 27.  Invoking a Siebel Web Service
    Click for full size image

The following is an example of invoking Siebel published Web Service using .NET.

// removed using declaration

namespace sieOppClnt

{

public class sieOppClnt : System.Web.Services.WebService

{

public siebOptyClnt()

{

InitializeComponent();

}

// WEB SERVICE CLIENT EXAMPLE

// The optyQBE returns a list of opty based upon the required input params. Since the input to the Siebelopty.QueryByExample method uses an Input/Output param, ListOfInterOptyIntfaceTopElmt will be passed by ref to Siebel. To add the Siebel Opportunity Web Service definition to the project, I chose to run the wsdl.exe utility to generate the necessary helper C# class for the service definition.

[WebMethod]

public ListOfInterOptyIntfaceTopElmt optyQBE(string acctName, string acctLoc, string salesStage)

{

Siebelopty svc = new Siebelopty();

ListOfInterOptyIntfaceTopElmt siebelMessage = new ListOfInterOptyIntfaceTopElmt();

ListOfInteroptyInterface optyList = new ListOfInteroptyInterface();

opty[] opty = new opty[1];

opty[0] = new opty();

opty[0].Account = acctName;

opty[0].AccountLocation = acctLoc;

opty[0].SalesStage = salesStage;

//assemble input to be provided to the Siebel Web Service. For the sake of simplicity the client will query on the Account Name, Location, and Sales Stage. Ideally additional checking to make sure that correct data is entered.

optyList.opty = opty;

siebelMessage.ListOfInteroptyInterface = optyList;

// invoke the QBE method of the Siebel Opportunity business service

svc.SiebeloptyQBE(ref siebelMessage);

// return the raw XML of the result set returned by Siebel. Additional processing could be done to parse the response.

return siebelMessage;

}

}

}

Integration Platform Technologies: Siebel eBusiness Application Integration Volume ll