Build it yourself

You can choose between two versions of the client application:

  1. The simple version of the client application which will just display the list of Business Processes installed on your WebSphere Process Server.
    To implement the simple version, follow the instructions in this chapter "Build it yourself".
  2. The advanced version of the client application which will create a business object, start a long-running process, and query the status ot the process and the results.
    To implement the advanced version, first follow the instructions in this chapter "Build it yourself" and then perform the additional steps described in the next chapter Advanced Version.

The paragraphs in this chapter describe the steps to build a most simple Microsoft® .NET® client application which uses the secured Web Services API delivered with WebSphere Process Server.
To develop the client application, we will use Microsoft Visual Studio® .NET 2005 and Microsoft Web Services Enhancements (WSE) 2.0 SP3.

In detail, the following steps are described:

Note: During this sample, we restrict ourselves to the Business Flow Manager API (BFM API) which can be used to interact with the BPEContainer. If you rather want to use the Human Task Manager API (HTM API) which can be used to interact with the TaskContainer, all steps are conceptually similar, but you will export the WSDL files from the TaskContainer application instead.

Find out URL for the WSDL on WebSphere Process Server

In this section, we determine the URL for the Web Services Description file (WSDL). We need this URL to access the WSDL file which is necessary to use the Web services interface.

The most simple case is when the following three conditions are met:

  • You have installed both Microsoft Visual Studio and WebSphere Integration Developer on your local machine;
  • As server, you run the integrated WebSphere Process Server which is shipped with WebSphere Integration Developer;
  • You want to run the client application only on the same machine where the WebSphere Process Server is running.

In this case, the URL is http://localhost:9080/BFMIF_widNode_server1/sca/com/ibm/bpe/api/sca/BFMWS/wsdl. After starting the server, you can use this URL in a Web Browser to display the WSDL file. Then proceed to the next section Create a new application project.

In the more general case, this is the URL:
http://yourhost:yourport/bpeContextRoot/sca/com/ibm/bpe/api/sca/BFMWS/wsdl.

Note: Replace yourhost with your server's internet address and yourport with the port of your server's HTTP transport.

Use the following steps to find out bpeContextRoot (the context root of the Web services interface for the BPE container application):

  1. Make sure your WebSphere Process Server is started.
  2. In a browser, open the administrative console.
    The default URL is
  3. In the navigation pane, expand Applications > Application Types and select WebSphere enterprise applications.
  4. Locate the application named BPEContainer_{your_nodename}_server1 and click on this application name.
  5. The configuration page for this application appears:
  6. Click on Context Root For Web Modules.
  7. The details page for the Context Root is displayed:
  8. The context root is listed with a leading slash.

Make sure the server is started and verify in a Web Browser that the URL you determined can be used to display a WSDL file before you proceed to the next section.

Create a new application project

We will create a simple .NET client application which uses the Web services interface. To do this, we first create the Visual C# Windows Application project named WebServiceClient. Follow these steps:

  1. In Microsoft Visual Studio, select File > New > Project.
  2. In the New Project window, as Project type select Visual C# > Windows and as Template select Windows Application.
  3. As Name, use WebServiceClient.
  4. Accept all other defaults and click OK. A new project is created, and an empty window with the name Form1 is created.

Create the Web services proxy

In this section, we access the Web Services Description file (WSDL) for which we previously determined the URL. Using this WSDL file, we then generate a C# proxy that allows to access the Web services operations as C# methods. Next, we modify the proxy to enable Web services security. Later on, we will use C# methods in our client code which is translated to Web service calls by this proxy.

Generate the C# proxy

First, we access the WSDL file. Do the following steps:

  1. Make sure that your WebSphere Process Server is started.
  2. In Microsoft Visual Studio, select Project > Add Web Reference.
  3. The wizard for adding a web reference opens.
  4. Into the URL field, paste the URL which you determined previously, for example,
  5. Note: If you want to run the .NET client application and WebSphere Process Server on different machines, you may want to use the server's unique internet address rather than "localhost". As well, you can use "localhost" for the moment and change the service endpoint later.

  6. Click Go. WebSphere Process Server will return the details for the BFMWS service.
  7. As Web reference name, enter MyBFMAccess and click Add Reference.

Now a C# proxy is created in the file Reference.cs.

Enable the proxy for Web services security

Note: For the steps in this section, the installation of the WSE component (Web Services Enhancements) is a prerequisite. See the Introduction chapter of this sample for information how to get the WSE component.

In this section we modify the proxy so the proxy can support secure Web services. Do the following steps:

  1. Select Project > Add Reference. The Add Reference window opens.
  2. Select Microsoft.Web.Services2 from the list and click OK.
  3. Select View > Object Browser. The tree view opens.
  4. Expand WebServiceClient > WebServiceClientMyBFMAccess.
  5. Right-click BFMWSService and select Go To Definition. The file Reference.cs is opened.
  6. Replace the string System.Web.Services.Protocols.SoapHttpClientProtocol by the string Microsoft.Web.Services2.WebServicesClientProtocol.
  7. This code change alters the superclass of the proxy; the new class is part of the Microsoft WSE component and allows to call the method RequestSoapContext(...) which we will use in the implementation below.

  8. On the toolbar, click the Save button .

Note: The change described in this section must be repeated whenever the proxy code is newly generated. Be aware that this code generation may happen automatically, for example, when you change the Web Reference URL via Solution Explorer > WebServiceClient > Web References > MyBFMAccess > Properties.

Create a simple client application

In this section, we create a tiny application, consisting of a single window which allows to display process templates.

Design a one push button application window

Complete the following steps:

  1. In the Design view, enlarge the Window Form1 like shown below so the several control elements will fit.
  2. In the Toolbox view, select TextBox and click inside the empty Form1 window.
  3. This creates a text box control element. Right-click this text box and select Properties.
  4. In the Properties view, change the Name from textBox1 to textBoxUserid.
  5. In the Toolbox view, select TextBox again and click inside the Form1 window, below the previously created text box.
  6. Right-click the second text box and select Properties.
  7. In the Properties view, change the Name to textBoxPassword.
  8. Change the value for UseSystemPasswordChar from False to True.
  9. In the Toolbox view, select Button and click inside the Form1 window, below the second text box.
  10. This creates a push button control element. Right-click on the button1 push button and select Properties.
  11. In the Properties view, this time do not change the Name but rather the Text value to the new text List Process Templates.
  12. Inside the Form1 window, resize the push button to make the new label completely visible.
  13. In the Toolbox view, select RichTextBox and click inside the Form1 window. Then enlarge the new element resize as this will contain the output later on.
  14. Optionally add two labels Userid: and Password: to the window. In addition, the screenshots for this sample will show a heading on the left-hand side which is a multiline label using enlarged font.
  15. On the toolbar, click the Save button .

Program the push button action

In this section, we program the push button so it takes the userid and password values and makes the C# proxy call the WebSphere Process Server. Complete the following steps:

  1. In the Design view for the Form1 window, move the mouse over the List Process Templates push button and double-click.
  2. The file Form1.cs opens, and caused by the double-click the empty method button1_Click(...) is included.
  3. Add the following two lines after the last using ... and before the namespace ... statement:
  4. using WebServiceClient.MyBFMAccess;
    using Microsoft.Web.Services2.Security.Tokens;

    These statements allows to use the short names rather than fully qualified names for several classes (BFMWSService, ProcessTemplateType, UsernameToken, PasswordOption) in the following lines of code.

  5. To implement the body of the method button1_Click, add the following lines between the curly braces:
  6.   try
      { // Get userid and password values and wrap it as UsernameToken:
        UsernameToken token = new UsernameToken(textBoxUserid.Text, textBoxPassword.Text, PasswordOption.SendPlainText);

        // Instantiate the proxy and attach the UsernameToken to the instance
        BFMWSService myService = new BFMWSService();
        myService.RequestSoapContext.Security.Tokens.Clear();
        myService.RequestSoapContext.Security.Tokens.Add(token);

        // Create an empty input object and run the query
        queryProcessTemplates queryInput = new queryProcessTemplates();
        richTextBox1.Text = " ... computing ..."; this.Refresh();
        ProcessTemplateType[] templateTypes = myService.queryProcessTemplates(queryInput);

        // Render the result: for each template, show three properties
        richTextBox1.Clear();
        if (0 == templateTypes.Length)
          richTextBox1.Text = "No process templates found on server.";
        for (int i = 0; i < templateTypes.Length; i++)
        {
          richTextBox1.AppendText("Name: " + templateTypes[i].name +
              ", Auto-delete: " + templateTypes[i].autoDelete +
              ", Long running: " + templateTypes[i].executionMode +
              "\n");
        }
      }
      catch (Exception exc)
      { // Whenever an error occurred, let the user know the details
        MessageBox.Show(exc.Message, "Error running sample",
                MessageBoxButtons.OK, MessageBoxIcon.Error);
        richTextBox1.Text = " ... sample failed with exception: " + exc.GetType();
      }

    This code creates a UsernameToken from the values in the text boxes for userid and password. Then it uses the proxy to query all process templates. Finally, it displays some of the properties.
    To keep the code simple, all potential runtime errors are mapped to one small code snippet.

    The top of your editor window will now look similar to this:

  7. On the toolbar, click the Save button .

Click on this link to see the complete source code of Form1.cs.

You have now finished the implementation of the simple client application. Optionally, you can now use Build > Build Solution to verify this solutions can be built without errors.

Then proceed to the next chapter Run the sample to work with the application.

As well, you can upgrade the simple client application and let the client application do more advanced Web Service operations, by following the instructions in the Advanced Version chapter.