Nav
You are viewing an older version of this section. Click here to navigate to the latest version.

Proxying Web Services with CXF

Normally when building CXF web services, you’ll databind the XML to POJOs. A CXF component might receive an OrderRequest object, or you might send an OrderRequest object via a CXF outbound router. However, it is often useful to work with the XML directly when building web services or consuming other web services. The CXF module provides the ability to do this.

Deciding How to Proxy Your Web Service

While many times you can proxy web services without using CXF (see Proxying Web Services), there are several cases where you might want to use CXF proxies:

  • To work directly with the SOAP body, such as adding XML directly to it

  • To take advantage of the CXF web service standards support to use WS-Security or WS-Addressing

  • To enforce WS-Policy assertions

  • To easily service a WSDL associated with your service

  • To transform a SOAP body

You would use wsdl-cxf instead of proxies when you want to invoke a service and one or more of the following applies:

  • You don’t want to generate a client from WSDL

  • You don’t have the raw XML

  • The service takes simple arguments such as string, int, long, or date

CXF proxies support working with the SOAP body or the entire SOAP envelope. By default only the SOAP body is sent as payload, but the payload mode can be set via the "payload" attribute to envelope if needed.

Server-side Proxying

To proxy a web service so you can work with the raw XML, you can create a CXF proxy message processor:


         
      
1
<cxf:proxy-service />

This will make the SOAP body available in the Mule message payload as an XMLStreamReader. To service a WSDL using a CXF proxy, you must specify the WSDL namespace as a property:


         
      
1
<cxf:proxy-service wsdlLocation="foo.wsdl"    serviceName="YOUR_WSDL_SERVICE"   namespace="YOUR_WSDL_NAMESPACE"/>

Client-side Proxying

Similarly, you can create an outbound endpoint to send raw XML payloads:


          
       
1
<cxf:proxy-client/>