Web Services with Axis 2, CXF and Maven – Part 2

After the service implementation is implemented and deployed we can start with the service client. For this part I like the way Apache CXF can be integrated in a Spring IoC container, so the service consumer will use Apache CXF for the client implementation.

Again, first we need to set up the Maven project with all required dependencies and build settings. The goal is to generate the client implementation with CXF and write a small test case. So we set up the typical maven project and add the cxf-codegen-plugin to the build settings. This Maven plugin has the goal wsdl2java which must be executed with the configuration pointing to the location of the WSDL of the deployed service. Often it is something like http://localhost:8080/axis2/services/Foo?wsdl. Also the project needs the Spring Framework and Apache CXF as dependency.

The second step is the test case. This one should be written using spring-tests which provides a basis for test cases requiring a Spring IoC container. The configuration file (also known as application-context file) requires the two CXF imports and the service client definition using jaxws:client tag. If the service provider requires authentication one can add the required processors to the output queue using jaxws:outInterceptors and e.g. the WSS4JOutInterceptor as a bean.


Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:


Du kommentierst mit Deinem WordPress.com-Konto. Abmelden / Ändern )


Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )


Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s