Francesco Marchioni
Francesco Marchioni

Reputation: 4338

Camel exposing CXF Web service


I'm trying to expose a JAX-WS Webservice (an annotated Java class) using Camel. When using a single parameter the Web service replies correctly. On the other hand when using as parameter an Object or multiple parameter it does not work. Here is the blueprint I have deployed on JBoss Fuse:

<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:camelcxf="http://camel.apache.org/schema/blueprint/cxf" xmlns:cxf="http://cxf.apache.org/blueprint/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd              http://camel.apache.org/schema/blueprint/cxf http://camel.apache.org/schema/blueprint/cxf/camel-cxf.xsd              http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd              http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
   <camelcxf:cxfEndpoint id="demo-target-cxf" address="http://localhost:9000/SourceExample/hello" serviceClass="com.sample.SourceExampleWSImpl" endpointName="SourceExamplePort" serviceName="SourceExampleService" />
   <camelContext xmlns="http://camel.apache.org/schema/blueprint" id="fuse-demo-route-exmple-cxf">
      <route id="demo-target-cxf">
         <from uri="cxf:bean:demo-target-cxf" />
         <transform>
            <simple>${in.body}</simple>
         </transform>
         <log message="Message input: ${in.body}" />
         <removeHeaders pattern="CamelHttp*" />
      </route>
   </camelContext>
</blueprint>

Here is the Web Service implementation class:

@WebService

public class SourceExampleWSImpl {


@WebMethod
    public int getTotal(int x, int y) {
        return x+y;
    }

}

The bundle ic correctly deployed on JBoss Fuse. When invoking the Web service, only the first parameter is evaluated. So for example, invoking with arguments 1 and 4:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sam="http://sample.com/">
   <soapenv:Header/>
   <soapenv:Body>
      <sam:getTotal>
         <arg0>1</arg0>
         <arg1>4</arg1>
      </sam:getTotal>
   </soapenv:Body>
</soapenv:Envelope>

returns:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <ns2:getTotalResponse xmlns:ns2="http://sample.com/">
         <return>1</return>
      </ns2:getTotalResponse>
   </soap:Body>
</soap:Envelope>

Any idea how to fix it ? Thanks

Upvotes: 0

Views: 634

Answers (1)

Claus Ibsen
Claus Ibsen

Reputation: 55550

Do you mean the expected output should be

1 + 4 = 5 because the following code should be called?

 public int getTotal(int x, int y) {
        return x+y;
    }

If so that does not happen, when you use camel-cxf as a bean then the bean only defines the contract, the code in the implementation is not in use.

If you just want a standard SOAP-WS and write java code that builds and process the SOAP requests/response then just use plain CXF.

Upvotes: 2

Related Questions