Integration Platform Technologies: Siebel Enterprise Application Integration > Web Services >

Examples of Invoking Web Services


The following two examples show sample flows of how to call an external Web service from a Siebel application, or how to call 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 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.
    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);

}

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 the Siebel Inbound Web Services view. 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 to create a proxy that can be used to invoke 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 is 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 invoking external application.
    Figure 27. Invoking a Siebel Web Service
    Click for full size image

The following is an example of invoking a 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. Because 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, the wsdl.exe utility was run 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, also check 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 Enterprise Application Integration Copyright © 2010, Oracle and/or its affiliates. All rights reserved. Legal Notices.