| By Berndt Hamboeck | Article Rating: |
|
| August 1, 2002 12:00 AM EDT | Reads: |
9,789 |
Web services is an emerging technology driven by the will to securely expose business logic beyond the firewall. Through Web services you can encapsulate existing business processes, publish them as services, search for and subscribe to other services, and exchange information throughout and beyond the enterprise. Web services will enable application-to-application interaction without the need to know anything about application implementations (languages, operating systems, tools) and without the need to write connectors to each new application.
Gartner defines a Web service as "a software component that represents a business function (or a business service) and can be accessed by another application (a client, a server, or another Web service) over public networks using generally available ubiquitous protocols and transports (i.e., SOAP over HTTP)."
What Is SOAP?
SOAP is an XML-based communication protocol and encoding format for interapplication communication. Originally conceived by Microsoft and UserLand software, it has evolved through several generations and the current spec, SOAP 1.1, is growing fast in popularity and usage. The W3C's XML Protocol Working Group is in the process of turning SOAP into a true open standard. As of this writing they have released a working draft of SOAP 1.2, which cleans up some of the more confusing areas of the 1.1 spec. SOAP is widely viewed as the backbone of a new generation of cross-platform, cross-language distributed computing applications termed Web services.
SOAP is a lightweight protocol for the exchange of information in a decentralized, distributed environment. It's an XML-based protocol that consists of three parts
- An envelope that defines a framework for describing what is in a message and how to process it
- A set of encoding rules for expressing instances of application-defined datatypes
- A convention for representing remote procedure calls and responses
Axis is one of several implementations of SOAP. The best known is Apache SOAP (http://xml.apache.org/soap/), now at version 2.2. (I discussed it in a previous article, "Web Services with PowerJ 4.0 and PB 8.0" [PBDJ, Vol. 9, issue 2]). Axis is also made by the Apache project but it's not part of the Apache SOAP project; it's a complete rewrite. Think of Axis as SOAP version 3. Axis has been under way for a long time. The first beta version was announced on March 15, 2002, and the second on April 29. It's the latter that's the focus of my article. The final version is expected to show up in late summer. You may read more about the Axis project on their Web site, http://xml.apache.org/axis/.
Why Axis?
In late 2000, the committers of Apache SOAP v2 began discussing how to make the engine more flexible, configurable, and able to handle both SOAP and the upcoming XML Protocol specification from the W3C.
After a while, it became clear that a rearchitecture from the ground up was required. Several of the v2 committers proposed very similar designs, all based around configurable "chains" of message "handlers" that would implement small bits of functionality in a very flexible and composable manner.
After months of continued discussion and coding effort in this direction, Axis now delivers the following key features:
What's in the Current Release (Beta 2)?
This release includes the following features:
- SOAP 1.1-compliant engine (with some SOAP 1.2 support as well)
- Flexible configuration/deployment system
- Support for "drop-in" deployment of SOAP services (JWS)
- Support for all basic types, and a type mapping system for defining new serializers/deserializers
- Automatic serialization/deserialization of JavaBeans, including customizable mapping of fields to XML elements/attributes
- Automatic two-way conversions between Java collections and SOAP arrays
- Providers for RPC and message-based SOAP services
- Automatic WSDL generation from deployed services
- WSDL2Java tool for building Java proxies and skeletons from WSDL documents
- Java2WSDL tool for building WSDL from Java classes
- Preliminary security extensions that can integrate with Servlet 2.2 security/roles
- Support for session-oriented services via HTTP cookies or transport-independent SOAP headers
- Preliminary support for SOAP with attachments specification
- An EJB provider for accessing EJBs as Web services
- HTTP servlet-based transport
- Standalone version of the server (with HTTP support)
- Examples, including a client and server for the SOAP builders community interoperability tests and experimental TCP and file-based transports
Installing Axis
First you have to download the Axis distribution from
http://xml.apache.org/axis/dist/beta2/xml-axis-beta2.zip and unzip it to C:\Axis.
Now create a directory called Axis in the Web application folder of your Jaguar installation (%JAGUAR%\Repository\WebApplication\axis). Copy the webapps/axis directory from the xml-axis distribution into this directory. You'll find the file web.xml in the WEB-INF directory, which is in the directory you just copied. Use Jaguar Manager to add a new Web application called axis and configure the two servlets (use web.xml for a description).
If you download the source code from www.sys-con.com/pbdj/ sourcec.cfm you'll have a complete Web application that you can import to EAServer.
From the "lib" directory in the WEB-INF directory, copy the JARs associated with the JAXP 1.1 XML-compliant parser of your choice. This generally means either the xerces.jar from the xml-xerces distribution (http://xml.apache.org/dist/xerces-j/), or the crimson.jar and jaxp.jar from the JAXP 1.1 reference implementation (http://java.sun.com/xml/xml_jaxp.html).
Note that EAServer comes with a distribution of xerces.jar, but this version did not work with the beta 2 of Axis. I recommend downloading the newest version.
Now try your installation by pointing your browser to http://localhost:8080/axis/servlet/AxisServlet. After a few seconds you should see the screen shown in Figure 1.
Deploying Your Code as a Web Service
The Apache people realized that it would be nice to be able to drop some code somewhere and have it become a Web service "just like that." This simplicity is a current trend; Microsoft has it in .NET, and Sybase in EAServer 4.1. But just how easy is it to:
- Deploy a piece of code?
- Write a client that accesses the Web service?
- Obtain the WSDL for the deployed Web service?
The first step is to write a simple PowerBuilder component for EAServer. The component will be a simple calculator and should have two functions: one for adding and one for subtracting two long variables and returning the result as long. We'll also add some logging functionality so we can see that there's no trick and it's our component producing the output for the Web service client (see Figure 2).
The component will be deployed to the package name, Axis. The component name should be calculator.
Download the finished application from PBDJ's Web site. After deploying the component don't forget to create stubs from within Jaguar Manager.
Now we need a wrapper class for our PowerBuilder component. This class also has our two functions - add and subtract - and an additional function in which we instantiate our PowerBuilder component (getComponent). The two functions take the passed arguments and route the call to the PowerBuilder component (see Listing 1).
As you can see, we've added a main function that we can use to test the class from outside EAServer. Before running the examples, you'll need to make sure that your CLASSPATH includes:
- xml-axis-beta2/lib/axis.jar
- xml-axis-beta2/lib/jaxrpc.jar
- xml-axis-beta2/lib/commons-logging.jar
- xml-axis-beta2/lib/tt-bytecode.jar
- xml-axis-beta2/lib/wsdl4j.jar
- A JAXP-1.1-compliant XML parser such as Xerces or Crimson
- % JAGUAR %/html/classes
- % JAGUAR %/java/classes
- %JAGUAR%\java\lib\easclient.jar
copy AxisCalculator.java %JAGUAR%
\Repository\WebApplication\axis\Calculator.jws
Having the code (with the .jws extension) in the Web application will deploy it and allow us to access it. If we open a browser and access the file (e.g., http://localhost:8080/axis/Calculator.jws) we'll be told that we're talking to a Web service. How easy was that?! A simple copy command and we're done.
Now that we have a deployed Web service, we need to access it. Let's look at a Java client that allows us to pass in a math operation (add or subtract) and the two amounts to work with (see Listing 2).
What's happening here? We create new Service and Call objects. These are the standard JAX-RPC objects that are used to store metadata about the service to be invoked. Then we set up our endpoint URL - this is the destination for our SOAP message. Next step is we define the operation (method) name of the Web service. Last but not least, we actually invoke the desired service, passing in an array of parameters - in this case one string.
You can see what happens to the arguments by looking at the SOAP request that goes out on the wire. The string argument is automatically serialized into XML, and the server responds with an identical string, which we deserialize and print.
Note: To actually watch the XML flowing back and forth between a SOAP client and server, you can use the included tcpmon tool.
java org.apache.axis.utils.tcpmon [listenPort targetHost targetPort]
java org.apache.axis.utils.tcpmon 8090 localhost 8080
After compiling and running the client we'll see that our PowerBuilder component is doing a good job and returns the right value:
java CalcClient -p8080 add 15 6
java CalcClient subtract 2 5
Note that you may need to replace the "-p8080" with whatever port your EAServer is running on and that the default port is 8080; if you use tcpmon, the port for it is 8090 (see Figure 3).
We can verify that it's really our PowerBuilder component doing the operation by looking into the Jaguar.log file. You should see an entry like this:
Jun 06 15:53:51 2002: axiscomponents add 15+6
A PowerBuilder Client for AXIS
We'll use PocketSOAP for our PowerBuilder client. PocketSOAP is a SOAP client COM component for the Windows family, originally targeted at the Pocket PC (hence the name). There is also a Win32 version that works on Windows 95/98/Me/NT4/2000/XP. The package includes an HTTP transport for making HTTP-based SOAP requests; however, the transport is separate from the main SOAP core, so any other transport could be easily added. It also includes an XML parser, used for parsing the response SOAP messages.
PocketSOAP is designed for interoperability and is regularly tested with over 30 of the leading SOAP tools, including:
- Apache SOAP and Axis
- Microsoft SOAP Toolkit v2.0
- Microsoft ASP.NET Web services
The core object is the Envelope object. This provides access to all the interesting stuff, like setting the method name and the parameters. Send the request to the Axis server with the HTTPTransport object; it supports redirects, cookies, proxies, authentication, proxy authentication, and SSL. The implementation is very easy, as you can see in Listing 3.
Conclusion
Axis is essentially Apache SOAP 3.0. It's a from-scratch rewrite, designed around a streaming model (using SAX internally rather than DOM). The intention is to create a more modular, more flexible, and higher-performing SOAP implementation (relative to Apache SOAP 2.0). It's very easy to deploy Web services using Axis. PowerBuilder developers can use PocketSOAP to call different Web services, including Apache SOAP and Axis.
Published August 1, 2002 Reads 9,789
Copyright © 2002 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Berndt Hamboeck
Berndt Hamboeck is a senior consultant for BHITCON (www.bhitcon.net). He's a CSI, SCAPC8, EASAC, SCJP2, and started his Sybase development using PB5. You can reach him under admin@bhitcon.net.
- Why SOA Needs Cloud Computing - Part 1
- Cloud Expo and The End of Tech Recession
- The Transition to Cloud Computing: What Does It Mean For You?
- A Rules Engine Built in PowerBuilder
- Sybase Named “Silver Sponsor” of iPhone Developer Summit
- How PowerBuilder Got Its Groove Back
- The Cloud Has Cross-Border Ambitions
- Ulitzer Names The World's 30 Most Influential Virtualization Bloggers
- Ulitzer Named "New Media" Partner of Greatly Anticipated iStrategy Event in Berlin
- Risks and Enterprise Mobility?
- Steps for Success in Enterprise Mobility?
- Are Mobile Luddites Resisting Mobility?
- The Difference Between Web Hosting and Cloud Computing
- Sybase CTO to Speak at 4th International Cloud Computing Expo
- Why SOA Needs Cloud Computing - Part 1
- Cloud Expo and The End of Tech Recession
- The Transition to Cloud Computing: What Does It Mean For You?
- Five Reasons to Choose a Private Cloud
- Seeding The Cloud: The Future of Data Management
- The Threat Behind the Firewall
- Economy Drives Adoption of Virtual Lab Technology
- Tips for Efficient PaaS Application Design
- A Rules Engine Built in PowerBuilder
- Sybase Named “Silver Sponsor” of iPhone Developer Summit
- Where Are RIA Technologies Headed in 2008?
- PowerBuilder History - How Did It Evolve?
- The Top 250 Players in the Cloud Computing Ecosystem
- Custom Common Dialogs Using SetWindowsHookEx
- DDDW Tips and Tricks
- OLE - Extending the Capabilities of PowerBuilder
- DataWindow.NET How To: Data Entry Form
- Book Excerpt: Sybase Adaptive Server Anywhere
- Sybase ASE 12.5 Performance and Tuning
- Working with SOA & Web Services in PowerBuilder
- Office 2003 Toolbar: A New Look For Your Old PowerBuilder App
- Dynamically Creating DataWindow Objects






























