Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
256 C HAPTER 10 Working with remote services For example, consider a procurement system that needs to communicate with a vendor's supply chain system. Maybe your company's human resources system needs to integrate with the payroll system. Or the payroll system may need to communicate with an external system that prints and mails paychecks. No matter the circumstance, your application will need to communicate with other systems to access services remotely. Several remoting technologies are available to you, as a Java developer, including Remote Method Invocation ( RMI ) Caucho's Hessian and Burlap Spring's own HTTP -based remoting Web services with JAX - RPC and JAX - WS Regardless of which remoting technology you choose, Spring provides broad support for accessing and creating remote services with several different technologies. In this chapter, you'll learn how Spring both simplifies and complements these remoting ser- vices. But first, let's set the stage for this chapter with an overview of how remoting works in Spring. 10.1 An overview of Spring remoting Remoting is a conversation between a client application and a service. On the client side, some functionality is required that isn't within the scope of the application. So the application reaches out to another system that can provide the functionality. The remote application exposes the functionality through a remote service. Suppose that we'd like to make some of the Spitter application's functionality avail- able as remote services for other applications to use. Perhaps in addition to the exist- ing browser-based user interface, we'd like to make a desktop or mobile front end for Spitter, as illustrated in figure 10.1. To support that, we'll need to expose the basic functions of the SpitterService interface as a remote service. The conversation between the other applications and Spitter begins with a remote procedure call ( RPC ) from the client applications. On the surface, an RPC is similar to a call to a method on a local object. Both are synchronous operations, blocking execu- tion in the calling code until the called procedure is complete. The difference is a matter of proximity, with an analogy to human communication. If you're at the proverbial watercooler at work discussing the outcome of the week- end's football game, you're conducting a local conversation--the conversation takes place between two people in the same room. Likewise, a local method call is one where execution flow is exchanged between two blocks of code within the same application. Third-party client Client object Spitter Spitter service get spittles Figure 10.1 A third-party client can interact with the Spitter application by making remote calls to a service exposed by Spitter.