Hi Marc
I think you can't get the return value form the Camel endpoint is you do
not set the value into the exchanger's out message.
After went through your process code, I found there is no parameters in
the request message, your process will not set out message's body.
BTW,
I just wrote a unit test[1] to show how to return the Boolean result ,
please check it out ( you need to use the latest Camel 1.4 snapshot to
run the test)
[1]
https://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerTest.java
Willem
mcobery wrote:
Hi,
I am running into a similar problem. When my return is a boolean (i.e. I
think any primitive, but need to perform more testing), my response is an
empty response when using Camel, but not when using CXF and JAXWS.
I have included the WebMethod definition, the SOAP returns, the Spring
configuration and the processing code.
Any help would be greatly appreciated. I am new to Camel but I think is is
great so far.
Regards,
Marc
Here is my WebMethod definition.
@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
@WebMethod(operationName = "create")
public boolean create( @WebParam(targetNamespace =
"http://cobery.com/compositeinterface", name = "composite") Composite comp);
Here is the return SOAP message from the Camel endpoint:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns1:createResponse xmlns:ns1="http://core.rulestream.com/composite"/>
</soap:Body>
</soap:Envelope>
Here is the return SOAP message from the CXF JAXWS endpoint:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Body>
<ns1:createResponse xmlns:ns1="http://core.rulestream.com/composite">
<return xmlns:ns1="http://core.rulestream.com">true</return>
</ns1:createResponse>
</soap:Body>
</soap:Envelope>
Here is the process method code:
public Boolean process(Exchange exchange) {
Message msg = exchange.getIn();
Composite comp = (Composite)msg.getBody(List.class).get(0);
if(comp != null)
{
System.out.println("comp name is " + comp.getName());
Boolean retVal = Boolean.FALSE;
MessageContentsList mcl = new MessageContentsList();
mcl.add(retVal);
exchange.getOut().setBody(mcl);
}
return Boolean.TRUE;
}
Here is the spring configuration:
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:soap="http://cxf.apache.org/bindings/soap"
xmlns:cxf="http://activemq.apache.org/camel/schema/cxfEndpoint"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://activemq.apache.org/camel/schema/cxfEndpoint
http://activemq.apache.org/camel/schema/cxfEndpoint/camel-cxf.xsd
http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
http://cxf.apache.org/bindings/soap
http://cxf.apache.org/schemas/configuration/soap.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<bean
id="transformationServ"
class="com.rulestream.core.knowledge.bso.impl.TransformationServiceImpl"
/>
<bean
id="compServ"
class="com.rulestream.core.knowledge.bso.impl.CompServiceImpl">
<property
name="transformationService"
ref="transformationServ" />
<property
name="compositeVersionDAO"
ref="compositeVersionDAO" />
<property
name="compositeDAO"
ref="compositeDAO" />
</bean>
<bean
id="compositeWs"
class="com.rulestream.services.knowledge.ws.impl.CompositeWebServiceImpl">
<property
name="entityBSO"
ref="compositeServ" />
</bean>
<jaxws:endpoint name="CompositeServiceJax"
address="/CompositeService"
serviceName="t:CompositeService"
xmlns:t="http://core.rulestream.com/composite">
<jaxws:implementor>
<ref bean="compositeWs"/>
</jaxws:implementor>
<jaxws:features>
<bean class="org.apache.cxf.feature.LoggingFeature"/>
</jaxws:features>
<jaxws:binding>
<soap:soapBinding version="1.2"/>
</jaxws:binding>
</jaxws:endpoint>
<cxf:cxfEndpoint
id="compService"
serviceClass="com.rulestream.services.knowledge.ws.impl.CompositeWebServiceImpl"
address="/CompositeRouterService"
endpointName="t:CompositeRouter"
serviceName="t:CompositeRouterService"
xmlns:t="http://core.rulestream.com/composite">
</cxf:cxfEndpoint>
<bean
id="createBean"
class="org.apache.camel.example.cxf.provider.CreateTesterBean" />
<bean
id="retrieveBean"
class="org.apache.camel.example.cxf.provider.RetrieveTesterBean" />
<camelContext
id="test_context"
xmlns="http://activemq.apache.org/camel/schema/spring">
<route>
<from uri="cxf://bean:compService" />
<choice>
<when>
<groovy>exchange.in.headers.operationName == 'create'</groovy>
<to uri="bean:createBean?methodName=process" />
</when>
<when>
<groovy>exchange.in.headers.operationName == 'retrieve'</groovy>
<to uri="bean:retrieveBean?methodName=processRetrieve" />
</when>
</choice>
</route>
</camelContext>
</beans>
willem.jiang wrote:
Hi Evgeny
You can do it by implementing a customer Invoker[1][2] just like the
CamelInvoker[3], which will perform the invocation to the java bean and
pass the parameter to the camel context.
And you need to add some codes to handle the (?)-endpoint's
configuration which could be same with camel-cxf endpoint.
But In this way, we just pass the parameter to the camel context, the
response from the camel will be useless for us.
[1]https://svn.apache.org/repos/asf/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/invoker/Invoker.java
[2]http://cwiki.apache.org/CXF20DOC/invokers.html
[3]https://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CamelInvoker.java
Regards,
Willem
pevgen wrote:
Thank you, Willem.
I understood your decision.
And i think, that may be create (?)-consumer (with cxf base), which can
create a full web-service from the clear java bean.
for example
class MyJavaBean {
public String getEcho(String value){
return " echo:" + value; }
}
and in the config-endpoint
<... serviceClass="MyJavaBean"
when client call the web-service (method "getEcho"), then (?)-endpoint
run
the method "getEcho" of "MyJavaBean" and return the result to the client.
and parameter will be to transmit in the some "to"-endpoint.
Thanks
Evgeny