This chapter describes the steps to upgrade the simple version of the application designed in the previous chapter Build it Yourself to issue some more advanced Web service API calls. This advanced version will use two more dialog windows: one new window is designed to take input from the end user, create a business object with these input data, and start a long-running process. Another new window is designed to query the process state and to display the output returned by the process once the process has finished.
In detail, in this chapter the following steps are described:
Note: Make sure that you have completed all steps in the previous chapter Build it Yourself before you proceed.
The advanced version of the client will use a particular business process template on the server side.
To define a business process and the appropriate data definitions is not the focus of this sample, but rather covered in
several other samples in the "Getting Started" section.
Thus, the definitions required for this sample sample are predefined as ZIP file in Project Interchange format. To use these definitions, go to the chapter Download of this sample
and import the webServiceAPISampleDotNET.zip
file as described in the first section "WebSphere Integration Developer 6.2 project".
In this section, we extract the data definition information from WebSphere Integration Developer and use it to generate a helper class. This helper class will assist us to serialize data from C# classes into XML data and to deserialize XML data into C# classes again.
Do the following steps:
BO_Address.xsd
, check the checkbox next to BO_Customer.xsd
.You now have exported the definition files for the business objects used in this project.
Next, you will export the input message definition and the output message definition from the WSDL file
that defines the process interface.
Do the following steps:
c:\temp\wsapiSample\MyXsd.xsd
The source of the wsdl file for the process interface is now visible in the editor.
<wsdl:types>
element, paste it into the file c:\temp\wsapiSample\MyXsd.xsd
xsd.exe
can be called. xsd MyXsd.xsd BO_Customer.xsd /classes
Now we have created a helper class we can use for serialization and deserialization which we can import into our .NET project. This file might look similar to this one: MyXsd_BO_Customer.cs.
The methods defined in the helper class can now be used in the client application code.
In this section, we add two more windows to our client application.
Complete the following steps:
A new form with name Form2 is displayed in the Design view.
textBoxFName
.textBoxLName
, textBoxSName
, and textBoxCName
.Submit data
. (Change only the Text field, do not change the Name field for the button.)Complete the following steps:
Refresh
. (Change only the Text field, do not change the Name field for the button.)Finally, a new button is created in the window Form1 which will be used to start the advanced sample.
Complete the following steps:
Advanced Sample
. (Change only the Text field, do not change the Name field for the button.) try
{ // Instantiate the proxy
BFMWSService myService = new BFMWSService();
richTextBox1.Clear();
// Get userid and password values and wrap it as UsernameToken
UsernameToken myToken = new UsernameToken(textBoxUserid.Text,
textBoxPassword.Text, PasswordOption.SendPlainText);
Form2 f2 = new Form2(myService, myToken);
f2.Show();
}
catch (Exception exc)
{ // Whenever an error occurred, let the user know the details
MessageBox.Show(exc.Message, "Error running advanced sample",
MessageBoxButtons.OK, MessageBoxIcon.Error);
richTextBox1.Text = " ... advanced sample failed with exception: " + exc.GetType();
}
The bottom of your editor window will now look similar to this:
Click on this link to see the complete source code of the new Form1.cs version.
You have now finished the implementation of the advanced client application. Optionally, you can now use
Then proceed to the next chapter Run the sample to work with the application.