WebReference.com - Part 5 of chapter 3 from Professional Java Web Services, Wrox Press Ltd. (1/6) | WebReference

WebReference.com - Part 5 of chapter 3 from Professional Java Web Services, Wrox Press Ltd. (1/6)

current pageTo page 2To page 3To page 4To page 5To page 6
[next]

Professional Java Web Services

Developing SOAP Clients

[The following is a continuation of our series of excerpts from chapter 3 of the Wrox Press title, Professional Java Web Services. The code for the examples discussed in this excerpt can be downloaded from the Wrox Web site (free registration required).]

In the previous section we discussed how to develop services using the Apache SOAP server-side API. In this section we focus on how to develop a SOAP client using the Apache SOAP client-side API. The Apache SOAP client-side API can be used to build a thick or thin client (that is, for a web browser, mobile phone, and so on). The SOAP client that we built for the Hello World service is an example of a thick client. We will focus on discussing web-based SOAP clients in this section. To illustrate the concepts, we will discuss the web-based SOAP client for the Job Resumé Repository Service that allows a user to submit and retrieve a resumé.

A user enters a resumé by using an HTML form that contains fields for entering resumé information. The name of the HTML file that contains the form is submit.html. It is shown below:

<html>
<head><title>Wrox Job Resume System - Submit Resume</title></head>
<body>
  <p align='center'><img align='middle' src='wroxlogo.gif'</img> <font face='Arial Narrow' size='5'><b>Job Resume Repository System</b></font></p>
 <p><font face="Arial Narrow" size="-1"><b>Submit Resume</b></font></p>
<form method="POST" action="servlet/submit">
<table border="0" width="44%">
    <tr>
      <td width="34%"><font face="Arial Narrow" size="2">First Name: </font></td>
      <td width="72%"><input type="text" name="firstName" size="20">
        <font face="Arial Narrow" size="2">   </font></td>
    </tr>
    <tr>
      <td width="34%"><font face="Arial Narrow" size="2">Middle Name: </font></td>
      <td width="72%"><input type="text" name="middleName" size="20"></td>
    </tr>
    <tr>
      <td width="34%"><font size="2" face="Arial Narrow">Last
        Name:        </font></td>
      <td width="72%"><input type="text" name="lastName" size="20"></td>
    </tr>
  </table>
  <p><font face="Arial Narrow" size="2"> Street Address:</font>
    <input type="text" name="address" size="30"></p>
  <p><font size="2" face="Arial Narrow">City:</font>
    <input type="text" name="city" size="22"><font face="Arial Narrow" size="2">   
  State</font>:<input type="text" name="state" size="4">      
  <font size="2" face="Arial Narrow"> Zip Code:</font><input type="text" name="zipcode" size="11">
  </p>
  <p><font face="Arial Narrow" size="2">Telephone Number:</font><input type="text" name="phoneNumber" size="20"></p>
  <p><font size="2" face="Arial Narrow">Education:</font></p>
  <p><textarea rows="5" name="education" cols="57"></textarea></p>
  <p> </p>
  <p><font size="2" face="Arial Narrow">Work History:</font></p>
  <p><textarea rows="5" name="workHistory" cols="57"></textarea></p>
  <p> </p>
  <p><font face="Arial Narrow" size="2">References:</font></p>
  <p><textarea rows="5" name="references" cols="57"></textarea></p>
  <p> </p>
  <p align="left">
    <input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2">
     &nbsp<font face="Arial Narrow" size="2">[<a href='index.html'>Home</a>]</font>
   </p>  
</form>
</body>
</html>

Once the form is populated and submitted, the form is processed using a servlet called SubmitServlet. The output sent back to browser after successfully processing the resumé is below:

Results of resume submission

Note that a unique identifier (UID) is generated for the resumé. This isn't being generated by the SubmitServlet, but is being created by the Job Resumé Repository Service. The uid is used to retrieve the resumé. If we click the View Resumé link on the above screenshot then the resumé will be retrieved from the service. This is done using another servlet called RetrieveServlet. If the retrieve resumé button is clicked the following page will be displayed:

Results of resume retrieval

In upcoming sections we will discuss the SubmitServlet and RetrieveServlet to see how the Apache SOAP client API is used to access the Job Resumé Repository Service.


current pageTo page 2To page 3To page 4To page 5To page 6
[next]

Created: June 17, 2002
Revised: June 17, 2002

URL: http://webreference.com/programming/java/webservices/chap3/5/