Wizard API updated!
Tim Boudreau has released a new version of the Swing Wizard library (version 0.997) that fixes the WizardException bug reported in JavaWorld's recent Open Source Java Project profile. The article's examples have been reworked to test out the new, improved WizardException. Thanks, Tim, for this helpful fix!
Open Source Java Projects: The Wizard API

Newsletter sign-up

Sign up for our technology specific newsletters.

Enterprise Java
View all newsletters

Email Address:

Clean up your wire protocol with SOAP, Part 3

Create SOAP services in Apache SOAP with JavaScript

So you're a Java developer trying to stay on the cutting edge? With all the uncertainty in the software industry, you want to know what the future of the Web holds and, more importantly, how you can leverage your years of Java expertise to its maximum. In searching for these answers, you won't have to look too far before you stumble upon SOAP.

SOAP (Simple Object Access Protocol) -- a wire protocol that uses XML for data encoding -- takes Java's platform independence and portability to a higher level of interoperability. In Part 2 of this four-part series on SOAP I introduced you to Apache SOAP, an implementation of the SOAP specification that easily creates SOAP-based applications. Using that implementation, you built two simple HelloWorld services and clients that invoked the sayHelloTo() method on those services. You learned that though creating SOAP services is quite simple, the client must complete most of the work. It must set up the Call object, call the invoke() method on it, and then interpret the Response object that returns as a result of the invocation.

Creating SOAP services using Apache SOAP can be even easier. The only prerequisite: you must know one of the prescribed scripting languages. Luckily for me -- and most other Java developers -- one of those languages is JavaScript. That's right, you can create SOAP services in Apache SOAP using JavaScript. In this article I'll show you how.

Read the whole series on SOAP:

Rebuild Apache SOAP

Apache SOAP's scripting support is built on top of the Bean Scripting Framework (BSF). Originally developed by IBM and now published as an open source project, BSF lets Java programs run scripts written in other languages and allows other scripting languages to use existing Java classes. Apache SOAP uses the former capability of BSF. The standard binaries that you download from Apache do not support scripting. More specifically, soap.jar does not contain the class org.apache.soap.server.InvokeBSF, which is the coupling/interface point between Apache SOAP and BSF. Knowing that not everyone using SOAP would have the required BSF jar and a scripting engine installed on their machine, the developers of Apache SOAP left out the scripting support in soap.jar. Since you are interested in scripting your SOAP service, you must rebuild the source to include the InvokeBSF class.

First you must download the source (soap-src-2.0.zip) from http://xml.apache.org/dist/soap/. Now unzip that file into the same directory where you installed Apache SOAP. In my case that is the root directory of my E drive. You should end up with an src subdirectory under the soap_2-0 directory that contains all the source code for Apache SOAP. Before you can rebuild that source, you must download the required BSF jar. You will find one at ftp://ftp.mozilla.org/pub/js/. Use it in conjunction with Mozilla's JavaScript engine Rhino; Rhino is available in a zip file at http://www.mozilla.org/rhino/download.html. I unzipped the file into the root directory of my E drive, which resulted in the creation of an E:\rhino subdirectory that contains Rhino. You are interested in js.jar from this installation.

1 | 2 | 3 |  Next >
Resources