Java Reference
In-Depth Information
Use a web service broker to expose business services to external clients based on open
web-based standards.
Strategies with the Spring Framework
Web services generally involve information exchange between two applications using
XML messages. These XML messages follow a standard called Simple Object Access Pro-
tocol (SOAP). The operations provided by the web service are described in a Web Service
Description Language (WSDL) file. The XML SOAP messages can be transported over
several network protocols such as HTTP, SMTP, and JMS. However, I will cover only HTTP
as the transport protocol.
Web Services with JAX-RPC
JAX-RPC is one of the most popular and simple mechanisms for developing web services
in Java. It can be used to create SOAP-based services called endpoints . The Spring con-
venience base class ServletEndpointSupport makes it simple to develop endpoints. This
class is useful since it provides access to the Spring application context, as well as acts as
the first point of contact in a web service. In this section, I will try to expose the policy
quotation service utilizing the Spring Framework and the Apache Axis web services
framework. Apache Axis provides a full SOAP-based JAX RPC implementation.
The first step in the development of a JAX RPC-based web service with Spring is to
define the service interface as in Listing 5-29. In this case, I will use the same
PolicyQuoteApplicationService implemented by the application service.
Listing 5-29.
public interface PolicyQuoteApplicationService {
public String BEAN_KEY = "policyQuoteApplicationService";
public double calculatePolicyQuote(String productCd,int age,
double sumAssured,int term);
The next step is to implement the endpoint class as in Listing 5-30. This endpoint
will implement the service interface, but the implementation methods delegate to the
actual application service.
Search WWH ::

Custom Search