Apache Axis

The Apache Web Services Project has produced Axis, an implementation of the W3C SOAP (Simple Object Access Protocol) standard.

Stylus Studio® uses Apache Axis in several ways:Apache Axis
• to query web services for exploring,
• to retrieve data through web services, and
• to generate code for web services.

Additionally, using the support of the XML Converters, web services through Axis can be built into your own applications, called and executed through XSLT and/or XQuery, and used in XML Pipelines and XML Reports.

Web Service Call Composer

Everything starts with the Web Service Call Composer. This lets you explore a UDDI Repository or WSDL file and see all of the operations that are exposed. Once we've identified a web service from here, we can save the call to it and reuse the output of that call anywhere we would normally use an XML document.

Web Service Demonstration

A more sophisticated demonstration of the Call Composer is available here, but for our purposes let's just use a simple call that fetches the weather from the United States National Oceanic & Atmospheric Administration (or NOAA).

Web services are described in structure by documents known as WSDL (Web Service Description Language) documents, and the URL for the NOAA weather WSDL document is http://www.webservicex.net/WeatherForecast.asmx?WSDL

In our copy of Stylus Studio® (evaluation version can be downloaded for free from here) we'll do File|New|Web Service Call, and in the "WSDL URL:" field we'll type the above URL. After pressing [Enter], the screen will look like this:

Apache Axis and Web Service Call Composer (Click to enlarge)
(click to enlarge)

In the Operations panel, each of the operations exposed by this web service are shown. We're going to use the GetWeatherByZipCode in a moment.

The Name/Type/Value columns list all of the input values that are required by the operation. Clicking in the Value column turns on an editor that allows you to type in a value. Bedford, Massachusetts is the home of Progress Software Corp., DataDirect Technologies' parent company, and we'll use their zip code in our demonstration.

Underneath that is a template for the actual SOAP request. Stylus Studio® uses the WSDL to create the request that would be sent to the SOAP service, typically through an HTTP "POST" or "GET". If you choose a different operation on the left, a new request XML document is created in that window, and above its approprate parameters are shown. As an alternative to entering the value in the top panel, you can actually modify the XML document in the window — it's live, so if I change <tns:ZipCode/> to <tns:ZipCode>01730</tns:ZipCode> the top panel will update as soon as I'm done typing. Similarly, when I change the top, the bottom document is updated.

WSDL Viewer

To look at the WSDL itself, click on the button illustrated here, or choose WebServiceCall|Open WSDL Document.

Open WSDL in Apache AXIS

Axis Demonstration

To see an actual operation occur, choose the GetWeatherByZipCode operation in the left panel, and then fill in the tns:ZipCode with the value 01730, and press the Send SOAP Request to Apache AXIS button or choose WebServiceCall|Send Request. The output window will then show the results of the call.

The result, in this case, would look something like this:

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <GetWeatherByZipCodeResponse xmlns="http://www.webservicex.net">
            <Day>Tuesday, November 21, 2006</Day>
           <WeatherImage> http://www.nws.noaa.gov/weather/images/fcicons/nfew.jpg</WeatherImage>

Axis Generating Java

Apache Axis can be used to generate the Java source code to call this web service, including the code to build the XML DOM in memory and do the sending. To generate these classes, use the WebServiceCall|Generate Java Web Service Client option, and after choosing the target directory for the generated source, all of the necessary code will be written for you.

Apache Axis generates web service call source code (Click to enlarge)
(click to enlarge)

Axis and XSLT

The XML Converters allow you to use converters anywhere you can use regular XML files. One of the special cases of this is that you can save the web service call from the first step above as a special file called a .wscc file, and then use it as input to XSLT or XQuery. As an example, instead of just retrieving the results, we can format them, all in one step. Or we can perform multiple operations using the XML Pipeline module.

Using the noaa.wscc we generated earlier and a little piece of XSLT code we'll call noaa.xslt (both of which can be downloaded by clicking on their names in this paragraph), we can reformat the results of the web service call so they look more attractive, like this:

BEDFORD, MA (42.4842873N, 71.2767944W)
Weather Day High Low
Apache Axis Primer Tuesday, November 21, 2006 49°F (9°C) 21°F (-6°C)
Apache Axis Introduction Wednesday, November 22, 2006 49°F (9°C) 37°F (3°C)
How to Use Apache AXIS Thursday, November 23, 2006 49°F (9°C) 34°F (1°C)
Apache AXIS Example Friday, November 24, 2006 46°F (8°C) 37°F (3°C)
Web Service Tutorial Saturday, November 25, 2006 50°F (10°C) 36°F (2°C)
Sample Web Service Sunday, November 26, 2006 47°F (8°C) 32°F (0°C)
Example Web Service Monday, November 27, 2006 48°F (9°C) 34°F (1°C)

Axis and XQuery

Just as Apache Axis web services can be used with XSLT, they can be used with XQuery.

But XQuery has another, direct way of calling web services. If you use the menu choice WebServiceCall|Copy XQuery Call to Clipboard, the actual source code for an XQuery call, using Apache Axis and either DataDirect XQuery or Saxon 8 XQuery, will be created — and it will look something like this:

(: This function requires the following items in the classpath if you are running on Java 1.5:)
(: axis-all.jar;xercesimpl.jar :)
(: If you are running on Java 1.4, you must also include xml-apis.jar :)

(: DataDirect XQuery function binding :)
declare namespace ws = "ddtekjava:com.stylusstudio.webservice.SOAPCall";
declare function ws:call($location as element(), $payload as element()) as document-node() external;


<tns:GetWeatherByZipCode xmlns:tns="http://www.webservicex.net">

Stylus Studio® is proud to be able to contribute to the Apache projects, and also to be part of a larger company that has a history of donating code to open source and helping to maintain it. DataDirect Technologies' sister division, Progress Sonic, is responsible for helping drive Axis forward (See Progress Sonic Standards Watch), and both organizations have committer rights on various Apache projects.

See the sweet results of open standards-based Web service development by downloading and evaluating today!


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Try STYLUS Apache AXIS Tools

Download a free trial of our powerful tools for building Web service applications for Apache AXIS.

Learn Stylus Studio in 6 Minutes

Can six minutes change your life? A new action-packed online video demonstration covers how to use Stylus Studio in just six minutes! Watch this video and change the way you develop XML applications forever!

Ask Someone You Know

Does your company use Stylus Studio? Do your competitors? Engineers from over 100,000 leading companies use Stylus Studio, and now you can ask someone from your own organization about their experiences using Stylus Studio.

Free Stylus Studio XML Training:
W3C Member