Java Reference
In-Depth Information
Invoking a Web Service Using XFire
By using XFire's client factory bean, you can invoke a web service just like a local bean. In the client bean
configuration file, client.xml , you can use XFireClientFactoryBean to create a proxy for the web service.
Then you can use this service as if it were a local bean.
<bean id="weatherService"
class="org.codehaus.xfire.spring.remoting.XFireClientFactoryBean">
<property name="wsdlDocumentUrl"
value=" http://localhost:8080/weather/services/WeatherService?wsdl" />
<property name="serviceInterface"
value="com.apress.springenterpriserecipes.weather.WeatherService" />
</bean>
Two properties have to be configured for an XFireClientFactoryBean instance. The WSDL URL
property specifies the URL for the WSDL file. The service interface property is for this factory bean to
create a proxy for the web service. The proxy will transfer the invocation requests to the web service
transparently.
Exposing an Annotation-Based Web Service Using XFire
XFire also supports the web service annotations defined by JSR-181: Web Services Metadata for the Java
Platform. It can automatically export your beans annotated with the web service annotations without
manual configuration. First of all, you have to annotate your web service implementation class with
these annotations.
Note To use the JSR-181 web service annotations, you have to copy xfire-jsr181-api-1.0-M1.jar (located
in the lib directory of the XFire installation) to the WEB-INF/lib directory.
package com.apress.springenterpriserecipes.weather;
...
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService(serviceName = "WeatherService")
public class WeatherServiceImpl implements WeatherService {
@WebMethod(operationName = "getTemperatures")
public List<TemperatureInfo> getTemperatures(String city, List<Date> dates) {
...
}
}
Search WWH ::




Custom Search