Cxf is integrated with spring to conveniently call WebService

Source: Internet
Author: User

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 ,)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.