### JAX-WS

WebService support is provided through the http://camel.apache.org/cxf.html[CXF,window=_blank]
component which integrates with the {wildfly} WebServices subsystem that also uses http://cxf.apache.org/[Apache CXF,window=_blank].


#### JAX-WS CXF Producer
The following code example uses CXF to consume a web service which has been deployed by the https://docs.jboss.org/author/display/WFLY8/JAX-WS+User+Guide[WildFly web services subsystem,window=_blank].

##### JAX-WS web service
The following simple web service has a simple 'greet' method which will concatenate two string arguments together
and return them.

When the {wildfly} web service subsystem detects classes containing JAX-WS annotations, it bootstraps a CXF endpoint. In this example
the service endpoint will be located at http://hostname:port/context-root/greeting.

[source,java,options="nowrap"]
----
// Service interface
@WebService(name = "greeting")
public interface GreetingService {
    @WebMethod(operationName = "greet", action = "urn:greet")
    String greet(@WebParam(name = "message") String message, @WebParam(name = "name") String name);
}

// Service implementation
public class GreetingServiceImpl implements GreetingService{
    public String greet(String message, String name) {
        return message + " " + name ;
    }
}
----

##### Camel route configuration
This RouteBuilder configures a CXF producer endpoint which will consume the 'greeting' web service defined above. CDI in conjunction with the camel-cdi component
is used to bootstrap the RouteBuilder and CamelContext.

[source,java,options="nowrap"]
----
@Startup
@ApplicationScoped
@ContextName("cxf-camel-context")
public class CxfRouteBuilder extends RouteBuilder {

    @Override
    public void configure() throws Exception {
        from("direct:start")
        .to("cxf://http://localhost:8080/example-camel-cxf/greeting?serviceClass=" + GreetingService.class.getName());
    }
}
----

The greeting web service 'greet' requires two parameters. These can be supplied to the above route by way of a `ProducerTemplate`.
The web service method argument values are configured by constructing an object array which is passed as the exchange body.

[source,java,options="nowrap"]
----
String message = "Hello"
String name = "Kermit"

ProducerTemplate producer = camelContext.createProducerTemplate();
Object[] serviceParams = new Object[] {message, name};
String result = producer.requestBody("direct:start", serviceParams, String.class);
----

#### Camel CXF JAX-WS Consumer

[source,xml,options="nowrap"]
----
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:cxf="http://camel.apache.org/schema/cxf"
       xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

    <cxf:cxfEndpoint id="cxfConsumer"
                     address="http://localhost:8080/webservices/greeting"
                     serviceClass="org.wildfly.camel.examples.cxf.jaxws.GreetingService" />

    <camelContext id="cxfws-camel-context" xmlns="http://camel.apache.org/schema/spring">
        <route>
            <from uri="cxf:bean:cxfConsumer" />
            <to uri="log:ws" />
        </route>
    </camelContext>

</beans>
----

#### Security

Refer to the https://github.com/wildfly-extras/wildfly-camel-examples/tree/master/camel-cxf-jaxws-secure[JAX-WS security section].

ifndef::red-hat-fuse[]

#### Code examples on GitHub

Example JAX-WS applications are available on GitHub.

* https://github.com/wildfly-extras/wildfly-camel-examples/tree/master/camel-cxf-jaxws[Camel CXF application,window=_blank]

endif::[]

ifdef::red-hat-fuse[]

#### Quickstart examples in Fuse on EAP

A quickstart example is available in your Fuse on EAP installation at `quickstarts/camel/camel-cxf-jaxws` directory.

endif::red-hat-fuse[]

