Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

XSLT

...

Feature

...

Table of Contents

The CXF XSLT Feature is alternative to CXF Transformation Feature providing flexible way to do the dynamic transformations of XML messages.
XSLT Feature applies custom XSL transformations to inbound and/or outbound messages.

...

It is necessary to configure XSLT script for inbound or/and outbound transformation. Example:

Code Block
xml
xml

    <bean id="xsltFeature" class="org.apache.cxf.feature.transform.XSLTFeature">
        <property name="inXSLTPath" value="requestTransformation.xsl" />
        <property name="outXSLTPath" value="responseTransformation.xsl" />
    </bean>

...

The feature can be configured from the code for JAX-WS or JAX-RS clients and endpoints. Example:

Code Block
xml
xml

	<jaxws:client id="customerService" serviceName="customer:CustomerServiceService"
		endpointName="customer:CustomerServiceEndpoint" address="http://localhost:9091/CustomerServicePort"
		serviceClass="com.example.customerservice.CustomerService">
		<jaxws:features>
			<ref bean="xsltFeature" />
		</jaxws:features>
	</jaxws:client>

	<jaxws:endpoint xmlns:customer="http://customerservice.example.com/"
		id="CustomerServiceHTTP" address="http://localhost:9090/CustomerServicePort"
		serviceName="customer:CustomerServiceService" endpointName="customer:CustomerServiceEndpoint"
		implementor="com.example.customerservice.server.CustomerServiceImpl">
		<jaxws:features>
                      <ref bean="xsltFeature" />
		</jaxws:features>
	</jaxws:endpoint>

...

Here is how a JAX-WS client can be configured:

Code Block
java
java

  CustomerServiceService service = new CustomerServiceService();
  CustomerService customerService = service.getCustomerServicePort();
  Client client = ClientProxy.getClient(customerService);
  XSLTOutInterceptor outInterceptor = new XSLTOutInterceptor(Phase.PRE_STREAM, StaxOutInterceptor.class, null,
                                                                   XSLT_REQUEST_PATH);
  client.getOutInterceptors().add(outInterceptor);

...