Java Reference
In-Depth Information
For a HessianServiceExporter instance, you have to configure a service object to export and its
service interface. You can export any bean configured in the IoC container as a Hessian service, and then
HessianServiceExporter will create a proxy to wrap this bean. When the proxy receives an invocation
request, it will invoke the corresponding method on that bean. By default, BeanNameUrlHandlerMapping is
preconfigured for a Spring MVC application. It maps requests to handlers according to the URL patterns
specified as bean names. The preceding configuration maps the URL pattern /WeatherService to this
exporter.
Now you can deploy this web application to a web container (e.g., Apache Tomcat 6.0). By default,
Tomcat listens on port 8080, so if you deploy your application to the weather context path, you can
access this service with the following URL:
http://localhost:8080/weather/services/WeatherService
Invoking a Hessian Service
By using Spring's remoting facilities, you can invoke a remote service just like a local bean. In the client
bean configuration file client.xml , you can use HessianProxyFactoryBean to create a proxy for the
remote Hessian service. Then you can use this service as if it were a local bean.
Note To invoke a Hessian or Burlap service, you have to include caucho-3.2.1.jar (located in the
lib/caucho directory of the Spring installation) in your classpath.
<bean id="weatherService"
class="org.springframework.remoting.caucho.HessianProxyFactoryBean">
<property name="serviceUrl"
value=" http://localhost:8080/weather/services/WeatherService" />
<property name="serviceInterface"
value="com.apress.springenterpriserecipes.weather.WeatherService" />
</bean>
You have to configure two properties for a HessianProxyFactoryBean instance. The service URL
property specifies the URL for the target service. The service interface property is for this factory bean to
create a local proxy for the remote service. The proxy will send the invocation requests to the remote
service transparently.
Exposing a Burlap Service
The configuration for exposing a Burlap service is similar to that for Hessian, except you should use
BurlapServiceExporter instead.
<bean name="/WeatherService"
class="org.springframework.remoting.caucho.BurlapServiceExporter">
<property name="service" ref="weatherService" />
<property name="serviceInterface"
value="com.apress.springenterpriserecipes.weather.WeatherService" />
</bean>
Search WWH ::




Custom Search