Recommended: Sing it, brah! 5 fabulous songs for developers
JW's Top 5
Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs
Page 2 of 7
Xerces-J-bin.1.2.0.zip. Unzipping this file will result in the creation of a xerces-1_2_0 subdirectory. As before, I've unzipped the file into the root directory of my E drive. You must configure your Web server
to use xerces.jar (which is in the xerces-1_2_0 subdirectory) -- as opposed to any native library/jar that came with your server -- for all XML parsing. For example, Tomcat
comes with an XML parser (jakarta-tomcat\lib\xml.jar) that has the DOM level 1 interfaces. Even if you put the xerces.jar in your classpath, any Java code running in Tomcat will find the wrong interfaces because the shell script/batch file that
you use to run Tomcat places your classpath at the end. So you must edit tomcat.bat (tomcat.sh for Unix) in the jakarta-tomcat\bin\directory and put xerces.jar at the front of the classpath that the script builds. That is what I did in my jakarta-tomcat\bin\tomcat.bat file:set CLASSPATH=E:\xerces-1_2_0\xerces.jar;%CLASSPATH%;%cp%
If you fall in Step 2's Category 2, then you must also configure your server to use xerces.jar.
Regardless of which category you fall into, in addition to xerces.jar, you must also set your Web server's classpath to use soap.jar from the soap-2_0\lib\ subdirectory.
Now, start your Web server and make sure that your installation is correct by pointing your browser to http://localhost:8080/apache-soap/admin. You should see an administration screen as shown in the figure below.
Apache SOAP administration tool
Now that you have set up Apache SOAP, let's put it to use with a simple HelloWorld application. In SOAP lingo, applications are called services. Typically, services are created in two steps, which may or may not be performed by the same person/organization. The first step is to define and implement the service itself in the language of choice: in this case, Java. The second step is to create clients that actually need and invoke the service. Let's look at the HelloWorld service first.
The HelloWorld service is the Apache SOAP implementation of the example I discussed in Part 1. The service expects to obtain a person/user's name and returns a customized hello message to the caller. The code below shows the complete implementation of the HelloWorld service:
package hello;
public class HelloServer
{
public String sayHelloTo(String name)
{
System.out.println("sayHelloTo(String name)");
return "Hello " + name + ", How are you doing?";
}
}
Is that all? That is too simple to be true!
Apache SOAP makes creating services extremely easy. Basically, a service consists of the business logic, which is code that
you would write regardless of how you made the service available to the rest of the world. In other words, the service is
not tainted by any SOAP-related code, because the Apache SOAP infrastructure -- which consists of the rpcrouter servlet and soap.jar -- handles all the intricacies for you. Let's talk briefly about those intricacies. Just how does Apache SOAP handle remote
procedure call (RPC) requests over HTTP? Understanding that will ease the creation of clients (yes, clients).