Pageflow and Form Guide

CHAPTER 11

Working with RPC-Style Web Services

This chapter explains how to create a pageflow that invokes an RPC-style Web Service. It includes these topics:

 
Top of page

About pageflows that use RPC-style Web Services

exteNd Director provides the Web Service Pageflow Wizard to help you create pageflows that execute Web Services. This wizard uses a Web Service activity to invoke the service.

The Web Service activity only provides support for document-style WSDL files. However, you can create a pageflow that invokes an RPC-style Web Service by using a Java activity.

Example    Here's an example of a pageflow that executes an RPC-style Web Service:

RPCPageFlow

Here's what the input page would look like at runtime:

TemperatureIn

Here's what the output page would look like at runtime

TemperatureOut

 
Top of page

Creating a pageflow that uses an RPC-style Web Service

To use an RPC-style Web Service in a pageflow, you need to:

 
Top of section

Generating the Web Service consumer

To generate a Web Service consumer, you need to run the Web Service Wizard. When you run the wizard, you provide a WSDL file as input. In this case, the WSDL file describes a Web Service that uses RPC-style bindings.

Specifying the project, package, and directory for the consumer   To ensure the generated classes can be found at runtime, you need to provide the following settings when you're running the wizard:

RPCWebServiceConsumerSettings

For more information    For complete details on how to generate a consumer, see the chapter on generating Web Service consumers in Utility Tools.

After running the wizard, you can test the Web Service consumer by running the Web Service Client Runner. However, before you can do this, you need to:

Editing the xxxClient.java file   Before using the generated xxxClient.java file, you:

Adding the archives required by the Web Services SDK to your project   For more information    For a complete list of the archives required, see the chapter on generating Web Service consumers in Utility Tools.

 
Top of section

Writing the Java activity class

A Java activity is a system activity that executes a Java class within the context of a pageflow. A Java activity allows you to write custom business logic that executes automatically without user intervention.

You can create a Java activity using the Java Activity Wizard, code the resulting Java class template, and add the activity in the Pageflow Modeler.

To invoke a Web Service from a Java activity, you need to include some Java code to:

Note that this Java activity also uses the scoped path API to get the zip code (ZIP) and set the temperature (TEMP) on the Session object.

Using a helper class to invoke the service   The exteNd Director API provides a helper class you can use to invoke a Web Service. This class is called WebServiceActivityHelper. It is located in the com.novell.afw.portal.portlet.pf package. The code example below shows the use of this helper class:

  import com.sssw.wf.api.*;
  import com.novell.afw.portal.portlet.pf.*;
  
  public class TemperatureJavaActivity implements EbiJavaActivity {
  	 public TemperatureJavaActivity() {
      }
  
      public void invoke(EbiContext context) {
          
  	 	 System.out.println("TemperatureJavaActivity");
  	 	 try {
  	 	 	 
  	 	 	 WebServiceActivityHelper wsHelper
  	 	 	 	 = new WebServiceActivityHelper();
  	 	 	 net.xmethods.sd.TemperaturePortType remote =
  	 	 	 	 (net.xmethods.sd.TemperaturePortType)
  	 	 	 	 wsHelper.getRemote(
  	 	 	 	  net.xmethods.sd.TemperatureService.class,
  	 	 	 	  net.xmethods.sd.TemperaturePortType.class);
  
  	 	 	 // get the ZIP from the portlet session
  	 	 	 String zip =
  	 	 	  (String)context.getEbiWhiteboard().getScopedValue( "ZIP" );
  	 	 	 float f = remote.getTemp(zip);
  	 	 	 context.getEbiWhiteboard().setScopedValue(
  	 	 	  "TEMP", String.valueOf( f ) );
  	 	 
  	 	 }
  	 	 catch (Exception e) {
  	 	 	 throw new RuntimeException (e);
  	 	 }
  	 	 	 
  ...
  }

 
Top of section

Creating the user interface for the pageflow

Typically, you'll want to create an input page as well as an output page for a pageflow that invokes a Web Service. The input page allows the user to enter values for parameters that should be passed to the service. The output page displays the data returned by the service.

Input page

Here's some HTML for a sample input page:

  <form name="form1" method="post" action="wsrp_rewrite?wsrp-urlType=blockingAction/wsrp_rewrite">
  <br/>
  	 <span class="portlet-form-field-label">
  	 	 Zip
  	 </span>
  	 <input class="portlet-form-field" type="name" name="zip" value="02630" size="20"> 
  	 <br/><br/>
  	 <input type="submit" name="verb" value="Continue">
  </form>

Output page

Here's some HTML for a sample output page:

  <form name="form1" method="post" action="wsrp_rewrite?wsrp-urlType=blockingAction/wsrp_rewrite">
  <br/>
  	 <span class="portlet-form-field-label">
  	 	 Zip Temperature : scopedpath?Session/TEMP/scopedpath
  	 </span>
  	 <br/><br/>
  	 <input type="submit" name="verb" value="Continue">
  </form>

In this example, the data returned (the temperature) is retrieved by means of a scoped path expression:

  scopedpath?Session/TEMP/scopedpath

 
Top of section

Creating the pageflow

Here's what the pageflow would look like:

RPCPageFlow

Here are the scoped paths for the flow:

RPCWebServiceScopedPaths

Specifying a Copy After operation for the input page  

The HTML input page would specify a Copy After operation that copies the zip code entered by the user into a variable on the Session scope:

RPCCopyAfterInput




Copyright © 2004 Novell, Inc. All rights reserved. Copyright © 1997, 1998, 1999, 2000, 2001, 2002, 2003 SilverStream Software, LLC. All rights reserved.  more ...