Create a web service with CXF using WS-SECURITY Signature action and expose it through the OSGi HTTP Service, the main purpose is to demonstrate how to use signaturePropRefId WSS4J configuration in OSGi container.
The web service is a simple JAX-WS web service with ws-security Signature and UsernameToken action called HelloWorldSecurity. The interface and the implementation are located in the src/main/java/org/ apache/camel/example/cxf/ws directory of this example.
The camel-context.xml file, located in the src/main/resources/META-INF/spring directory:
Configures the web service endpoint as follows:
<jaxws:endpoint id=“helloWorld” implementor=“org.apache.camel.example.cxf.ws.HelloWorldImpl” address=“/HelloWorldSecurity”> jaxws:inInterceptors </jaxws:inInterceptors> </jaxws:endpoint>
<util:properties id=“wsCryptoProperties”>
<prop key="org.apache.ws.security.crypto.provider">org.apache.ws.security.components.crypto.Merlin</prop> <prop key="org.apache.ws.security.crypto.merlin.keystore.type">jks</prop> <prop key="org.apache.ws.security.crypto.merlin.keystore.password">storepassword</prop> <prop key="org.apache.ws.security.crypto.merlin.keystore.file">server-truststore.jks</prop>
</util:properties>
You will need to compile this example first:
mvn install
To run the example on Apache Karaf 4.x or newer
Launch the server
karaf / karaf.bat
Add features required
feature:install cxf feature:install camel feature:install camel-cxf
Deploy the example
install -s mvn:org.apache.camel.example/camel-example-cxf-ws-security-signature/${version}
To view the service WSDL, open your browser and go to the following URL:
http://localhost:8181/cxf/HelloWorldSecurity?wsdl
To run the java code client:
Change to the <camel_home>/examples/camel-example-cxf-ws-security-signature directory.
Run the following command:
mvn compile exec:java
If the client request is successful, it will print out: <soap:Envelope xmlns:soap=“http://schemas.xmlsoap.org/soap/envelope/”>soap:Body<ns2:sayHelloResponse xmlns:ns2=“http://cxf.apache.org/wsse/handler/helloworld”>Hello CXF</ns2:sayHelloResponse></soap:Body></soap:Envelope>
If you hit an problems please let us know on the Camel Forums http://camel.apache.org/discussion-forums.html
Please help us make Apache Camel better - we appreciate any feedback you may have. Enjoy!
The Camel riders!