At this point (Workshop 8.1), you can create a Web Service from bottom up. That is, you can create a service implementation and then generate the WSDL from it. You can not create a new service based on some one else’s WSDL file.

Operations available from a Web Service can be invoked from a Page Flow. To do so, we need to create a Web Service Control in the project where the Page Flow is being developed. (The Web Service itself can be developed in another application or in another system – in WebSphere for example). The Web Service Control acts as a client side proxy. It makes the process of invoking a service operation as easy as calling a Java method.

In this tutorial, we will develop a service that can authenticate a user.


This tutorial depends on WLSKB002. Make sure that you have successfully completed that tutorial. Open the BasicApp application in Workshop unless you already have it open.


First, we will create a plain Java class that will serve as the input and output for the Web Service.

Right click on the BasicAppWeb project and select New->Folder. Enter MyWebServices as the folder name. Right click on the MyWebServices folder and select New->Java Class. Set the name of the class to and click on Create. Add the following member variables to the class.

 public String userId;
 public String password;
 public int resultCode;
 public String message;

Save and close the file.

Right click on MyWebServices and select New->Web Service. Enter AuthenticationService.jws as the file name. Click on Create.

Right click on the service and select Add Method. Hit Enter. Click on the newMethod1 hyperlink. Note the @common:operation XDoclet tag above the method indicating that this method is one of the operations offered by this service.

Change the method signature to as follows.

public AuthInfo authenticateUser(AuthInfo info)

Add the following implementation code.

public AuthInfo authenticateUser(AuthInfo info)
    if (info.userId.equals("bob") && info.password.equals("bobcat")) {
        info.resultCode = 1;
    } else {
        info.resultCode = 0;
        info.message = "Service Error:: Invalid user ID or password";

    return info;

Save and close the file.


A service is unit tested in the project where it is developed. From the menubar, select Debug->Start.

Click on the Test XML tab.

In the SOAP body text area, set the <userId> tag value to bob and <password> tag value to bobcat. Click on the authenticateUser button.

In the result page, scroll down and locate the Service Response section. Make sure that the resultCode value is 1.

Scroll up. Click on the Test Operations link. Try other user ID and password values.


A Page Flow can act as a consumer of a Web Service. The Page Flow may be developed in a separate application than where the Web Service is developed. To keep things simple, we will use the LoginFlow Page Flow.

A consumer accesses a Web Service through a Web Service Control. We need the WSDL file for the service to generate the control’s code. Right click on AuthenticationService.jws and select Generate WSDL File. System will generate AuthenticationServiceContract.wsdl.

Right click on the LoginFlow folder and select New->Java Control.

Select Web Service. Enter AuthServiceControl as the file name. Click on Next. Use the Browse button to locate the MyWebServices/AuthenticationServiceContract.wsdl file. Click on Create. System will create AuthServiceControl.jcx and open it in an editor. Click on the Source View tab at the bottom of the editor. Notice, how system has added the AuthInfo inner class. Close the editor.

Double click on LoginFlowController.jpf to open the Page Flow in the editor. Click on the Action View tab at the bottom of the editor. Drag AuthServiceControl.jcx and drop it on the editor. Click on the Source View tab. Notice, how the system has added a control member variable as shown below.

 * @common:control
private LoginFlow.AuthServiceControl authServiceControl;

Change the implementation of the Login() action method as follows.

protected Forward Login(LoginFormBean form)
    String forward_name = "";
    String message = "";

    AuthServiceControl.AuthInfo info = new AuthServiceControl.AuthInfo();

    info.userId = form.getUserId();
    info.password = form.getPassword();

    info = authServiceControl.authenticateUser(info);

    if (info.resultCode == 1) {
        forward_name = "success";
        getRequest().getSession().setAttribute("userId", form.getUserId());
    } else {
        forward_name = "failed";
        message = info.message; 
    //Store the message in the request context
    getRequest().setAttribute("message", message);

    return new Forward(forward_name);

Save changes.


Open a web browser. Enter the URL: http://localhost:7001/BasicAppWeb/LoginFlow/LoginFlowController.jpf

Make sure that you can only login as bob with password bobcat. Try creating an error condition.


A few things to remember from this tutorial.

  1. A Web Service is implemented in Workshop from a Java class with .jws extension.
  2. A public method within this can be adorned with the @common:operation XDoclet tag to make that method an operation offered by the service.
  3. A Web Service can be (and should be) unit tested before developing a consumer.
  4. The process of developing a consumer is same if the wevice was developed in another project or another system such as .Net or WebSphere.