Tutorials : Using Apache Axis version 1 to build Web Services :

Testing the DVDService

A real nice feature for testing a service is to use the browser. Enter the name of the service and the name of the method to test, e.g.:

  http://localhost:8080/axis/services/DVDService?method=getTitles

If you’re using an XML compliant browser like Internet Explorer then you’ll see something like this:

(Click on the picture to enlarge it)

Among the SOAP elements you can see that a Vector is returned and it contains the titles of 3 DVDs, taken from the XML-file specified in the DVDService code.

Let’s stop for a minute and consider what we’ve got. We’ve written a Java class called DVDService, which contains no code that relates to web services. We’ve copied the class file to the Axis directory structure and deployed it with the adminclient. At this point we’re already able to make a request that shows the SOAP reply. Let’s try with some other service methods.

The getDetails method needs an index of the DVD to locate:

I’ve specified i=1 in the URL, but you can type any name you want.

The result from getDetails is actually a DVD bean, so the structure of the reply is more complex this time. But you can easily find the bean properties: id, title, length, and actors.

It’s tempting to try to get details with an index that is too high. Let’s try index=10:

 

Actually a very kind error message - "Sorry, something seems to have gone wrong" - don’t you think? The exception that was thrown comes from the getDetails method in the DVDService class. By the way: this screen does not contain an XML reply. Use the browsers "View Source" facility to see that this is plain HTML. The communication between the browser and Axis is not like a real web service. The browser uses HTTP GET and receives an HTML error reply. A "normal" web service client will use HTTP POST and will always receive an XML reply.

How to Add Java Applets to Your Site

New on the Java Boutique:

New Review:

Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling API boasts simplicity, ease-of-integration, a well-rounded feature set, and it's free!

New Applet:

Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA sequences into three useful formats.

Elsewhere on internet.com:

WebDeveloper Java
Lots of Java information on webdeveloper.com

WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.

ScriptSearch Java
Hundreds of free Java code files to download.

jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.