Siebel Portal Framework Guide > Delivering Content to External Web Applications > Connecting to the XML Web Interface >

Submitting Requests Using the Web Engine Interface


Using Siebel's Object Interfaces you can access business services. The Web Engine Interface business service allows you to make requests to the Siebel Web Engine without having to submit requests through the Web server. Commands can be a query string or XML command block. The response is in the XML output property set of the business service.

For example, using the com.siebel.data.SiebelDataBean JavaBean class, you can access SWE as a business service from within the JSP environment. The SiebelDataBean provides a direct connection to SWE using the SISNAPI protocol; you can establish this connection without going through a Web server and the Siebel Web Extension plug-in. Once the data bean is instantiated, the SWE business service is obtained as an instance of com.siebel.data.SiebelService by calling the GetService() method on the data bean with the service name "Web Engine Interface."

The following code fragments show four tasks required to make the request:

  1. Instantiate the business service.
  2. Define the input properties.
  3. Invoke the method.
  4. Define the output property.

NOTE:  For the complete code sample, see Web Engine Interface Code Sample).

For example, the following code fragment instantiates the Web Engine Interface business service:

{
     SiebelDataBean sdBean = new SiebelDataBean();
     sdBean.login(conn, uName, passwd, locale);
     SiebelService service = sdBean.getService("Web Engine      Interface");
      . . .
}

The following code fragment defines the input properties for invoking the request method:

{
     SiebelPropertySet pi = sdBean.newPropertySet();

     pi.setProperty("J", "0");                  // Mode
     pi.setProperty("E", getServerName());      // ServerName
     pi.setProperty("F", getServerPort());      // ServerPort
     pi.setProperty("A", "POST");               // Method
     pi.setProperty("B", "");                   // RequestURI
}

You can invoke SWE business service methods by calling the SiebelService class method InvokeMethod() and passing in the method name and the input and output property sets (com.siebel.data.SiebelPropertySet). Results from the method invocation are generated as a property in the output property set. Here is a sample code fragment for invoking the "Start" method:

{

     SiebelPropertySet pi = sdBean.newPropertySet();
     SiebelPropertySet po = sdBean.newPropertySet();

     printInfo("Initializing SWE......");
     pi.setProperty("A", getUserName());     // UserName
     pi.setProperty("B", "80");              // HTTPPort
     pi.setProperty("C", "443");             // HTTPSPort
     pi.setProperty("D", getServerName());   // ServerName
     pi.setProperty("G", "F");               // UseCookie
     // initialize the swe
     if (swe.invokeMethod("Start",pi,po))
     {
          printInfo("Done initializing SWE!");
          //     printPS(pi, "Input PropertySet");
          printPS(po, "Login Output PropertySet");
     }
     else
     {
          printInfo("Failed to initialize SWE!");
     }
}

Query String

Using the Web Engine Interface, you can send requests to SWE either as a URL query string or as an XML document in the request body data. To send a request using a URL, set the property "QueryString" to the URL query string with all the SWE commands and parameters.

For example, the following code sample defines the input properties (Step 2 in the SiebelDataBean example) using a query string:

{
     SiebelPropertySet pi = getInputPropertySet(query);
     String query = "SWECmd=ExecuteLogin&SWEDataOnly=1&SWEUserName=SADMIN&SWEPassword=SADMIN&SWESetMarkup=XML";
     pi.setProperty("C", query);          // QueryString
}

The following code fragment invokes the Request Web Engine Interface business service method (Step 3 in the SiebelDataBean example):

     boolean result = swe.invokeMethod("Request", pi, po);

NOTE:  The Request method is the most commonly used Web Engine Interface method.

XML Command Block

To send a request using an XML command block, set the input properties "RequestBodyData," "RequestBodyLength," and "RequestBodyLengthTotal." The property "RequestBodyData" must contain the XML request as specified in Outbound DTD. You should either leave the query string blank or make sure it does not contain the parameter "SWECmd" or its short form "C" (for example, SWECmd=GotoView or C=Gv).

For example, the following code sample defines the input properties (Step 2 in the SiebelDataBean example) using an XML command block:

{
          String xmlRequest = "<EXEC>" +
          "<CMD NAME=\"SWECmd\" VALUE=\"GotoPageTab\">" +
          "<ARG NAME=\"SWEScreen\">Opportunities Screen</ARG>" +
          "<ARG NAME=\"SWESetMarkup\">XML</ARG>" +
          "</CMD>" +
          "</EXEC>";

          xmlRequest = "<?xml version=\"1.0\"?> " + xmlRequest;
          String len = (new Integer(xmlRequest.length() *           2)).toString();
          pi.setProperty("S", len);    // RequestBodyLength
          pi.setProperty("T", len);     // RequestBodyLengthTotal
          pi.setProperty("U", xmlRequest);     // RequestBodyData
}

The following code fragment invokes the Request Web Engine Interface business service method (Step 3 in the SiebelDataBean example):

boolean result = swe.invokeMethod("Request", pi, po);

Siebel Portal Framework Guide