O'Reilly logo

Java and SOAP by Robert Englander

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

11.3. Creating a JAX-RPC Service

Back in Chapter 9 we talked about building proxy services, which sit between client applications and other services. In that chapter, the back-end service with which the proxies communicated was located at http://mindstrm.com:8004/glue/urn:CorpDataServices. Let's do the same thing again, only this time we'll build our proxy service using the JAX-RPC reference implementation.[1] This example allows us to see how JAX-RPC interoperates with GLUE, and gives us a chance to build both a service and a client using JAX-RPC.

[1] I'm assuming you've downloaded and installed the Java Web Services Developer Pack already, and verified that it is working properly.

The first step in building the service is to write a Java interface for it, which I'll call javasoap.book.ch11.services.IStockServiceProxy. This interface must implement the java.rmi.Remote interface because JAX-RPC makes use of the Java RMI package. This strategy is fairly common because Java RMI provides a good distributed computing abstraction. The methods in the interface should be defined to throw RemoteException, which also comes from the java.rmi package. We'll define one method, getStockQuote( ), which takes a string parameter for the stock symbol and returns an instance of javasoap.book.ch9.services.ProxyQuote. There's no need to create a new class for returning a quote; we've already done it in Chapter 9. Here's what the code looks like for the IStockServiceProxy interface:

package javasoap.book.ch11.services; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required