RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


JAX-RPC Evolves into Simpler, More Powerful JAX-WS 2.0 : Page 4

The new Java Architecture for XML Web Services (JAX-WS) will replace JAX-RPC in the upcoming Java EE 5 and Java 6 (codename: Mustang). Learn all about JAX-WS 2.0 and see how to use it to transform a Java class into a Web service.


Transform Existing Java Classes into a Web Service/Client

A good demonstration of the development process is to customize the example from the previous section using your own Java class file. Add the "@WebService" annotation to the line after the imports and make the following changes to the additional files in order:
  1. Copy the JAXWS_EXAMPLE directory and change the two directories named "simpleExample" in "simpleExample/src/simpleExample" to your project name.
  2. Replace SimpleJAXWS.java and SimpleException.java with your new @WebService java file and any accompanying exceptions.
  3. Rename SimpleMethodClient.java to your class name.
  4. Open all the .java, .properties, and .xml files (including build.xml) in an editor, and use batch search/replace to make the following changes (be sure the replacements are case sensitive):
    • Replace all "simpleexample" references with your project name.
    • Replace all "simpleMethod" references with your method name.
    • Replace all "SimpleJAXWS" references with your class name.
    • Replace all "simplemethod" references with your URL pattern.
    • Replace all "SimpleException" references with your exception class name.
    • Replace all remaining "SimpleMethod" references with your method name (these occur in pointers to the derivative classes).
  5. Now you must edit the client class in accordance with the parameters and return the type of the Web service.
  6. Lastly, run the ant targets server and client, and run the same as above.

By following these steps you have transformed your own Java class into a Web service, enabling it to communicate over a network in a distributed computing environment.

Raw SOAP for Web Services Is Now Obsolete

With the advent of JAX-WS, the use of raw SOAP for Web services has become deprecated. This means that popular projects such as Apache Axis (Apache's implementation of SOAP) are no longer necessary for Web service developers. By abstracting the protocol binding, JAX-WS can provide simultaneous support for SOAP 1.1 and 1.2. By utilizing annotations, simplified build tools, and JAXB, JAX-WS removes many of the unnecessary complications of JAX-RPC.

John J. Yates has been a professional Java programmer for six years working on projects ranging from e-commerce to artificial intelligence. You can find his blog at www.JohnJYates.com/blog.
Email AuthorEmail Author
Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date