Can WebService be conveniently called in spring? cxf provides a convenient factory class for convenient calling.
Cxf provides a factory class Org. apache. cxf. jaxws. jaxwsproxyfactorybean, which can be obtained through the URL and stub Interface Class stub proxy (Org. apache. cxf. jaxws. jaxwsproxyfactorybean. create ). You can configure jaxwsproxyfactorybean to bean in spring, and then configure the stub interface class to bean, but generate an instance through the factory method. The configuration is as follows:
<Bean id = "subfactory" class = "org. Apache. cxf. jaxws. jaxwsproxyfactorybean">
<Property name = "serviceclass"
Value = "com. Test. Web. Service. subservice"/>
<Property name = "Address"
Value = "http: // localhost: 8080/testwebservice/services/subservice"/>
</Bean>
(Note: The serviceclass attribute is a sub interface class, and the address is the path of WebService ).
<Bean id = "subservice" class = "com. Test. Web. Service. subservice"
Factory-bean = "subfactory" factory-method = "CREATE"/>
In this way, to call WebService in other beans, you only need to inject the bean subservice into the bean to be used, and then you can call WebService transparently as you call the local bean.
(Note: COM. Test. Web. Service. subservice is an interface class generated through wsdl2java ,)