Recently I have been doing quite a bit of work around Apache CXF, both on the server side and the client side. Over the next few weeks I will post some of the tricks I have learnt.

In this post I will summarise one of the cxf-codegen-plugin options I used to assist me while consuming WCF web services using Apache CXF. When dealing with WCF based services, and indeed any WSDL which uses more than one namespace it is handy knowing how to control name spaces and how these translate into packages in your java stubs.

When consuming WCF services you may encounter either the default namespace for services which is, or more commonly, one more custom name spaces configured by the developer.

Below is an example of using selective namespace mappings by specifying the -p option in the cxf-codegen-plugin. This switch instructs wsdl2java to map all xml objects in a given namespace into the java package supplied.

So if we had a WCF based registration service which included the following namespaces: * * *

Only the would be mapped into java package.

The reason this is done is typically to avoid name clashes and issues with overlapping data objects used by more than one service in the one namespace.

<!-- Generate client using WSDL -->

As most of the samples on the Apache CXF website are in opinion way to simplistic, I am putting together some more extensive client and server samples which I will post up on wolfeidau Github soon.

comments powered by Disqus