ppalaga commented on code in PR #15573: URL: https://github.com/apache/camel/pull/15573#discussion_r1760834448
########## components/camel-cxf/camel-cxf-soap/src/main/docs/cxf-component.adoc: ########## @@ -567,7 +567,13 @@ and setDefaultBus properties from spring configuration file. == Examples -=== How to create a simple CXF service with POJO data format +=== How to consume a message from a Camel CXF endpoint in POJO data format Review Comment: ```suggestion === Consume a message from a Camel CXF endpoint in POJO data format ``` Shorter & same meaning ########## components/camel-cxf/camel-cxf-soap/src/main/docs/cxf-component.adoc: ########## @@ -590,86 +600,50 @@ And implementation: package org.apache.camel.component.cxf.soap.server; -@WebService(name = "EchoService", serviceName = "EchoService", targetNamespace = "http://server.soap.cxf.component.camel.apache.org/") -public class EchoServiceImpl implements EchoService { +import jakarta.jws.WebService; + +@WebService(name = "TextService", serviceName = "TextService", targetNamespace = "http://server.soap.cxf.component.camel.apache.org/") +public class TextServiceImpl implements TextService { @Override - public String echo(String text) { - return text; + public String upperCase(String text) { + return text.toUpperCase(); } + @Override + public String lowerCase(String text) { + return text.toLowerCase(); + } } ----- -We can then create the simplest CXF service (note we didn't specify the `POJO` mode, as it is the default mode): - -[source,java] ----- - from("cxf:echoServiceResponseFromImpl?serviceClass=org.apache.camel.component.cxf.soap.server.EchoServiceImpl&address=/echo-impl")// no body set here; the response comes from EchoServiceImpl - .log("${body}"); ---- -For more complicated implementation of the service (more "Camel way"), we can set the body from the route instead: +We can then create the simplest CXF service (note we didn't specify the `POJO` mode, as it is the default mode) in "Camel way": [source,java] ---- - from("cxf:echoServiceResponseFromRoute?serviceClass=org.apache.camel.component.cxf.soap.server.EchoServiceImpl&address=/echo-route") - .setBody(exchange -> exchange.getMessage().getBody(String.class) + " from Camel route"); + from("cxf:textServiceResponseFromRoute?serviceClass=org.apache.camel.component.cxf.soap.server.TextService&address=/text-route", + .process(exchange -> { + String operation = (String) exchange.getIn().getHeader(CxfConstants.OPERATION_NAME); + String inputArg = ((MessageContentsList) exchange.getIn().getBody()).get(0).toString(); + String result = null; + if (operation.equals("upperCase")) { + result = inputArg.toUpperCase(); + } + else if (operation.equals("lowerCase")) { + result = inputArg.toLowerCase(); + } + exchange.getIn().setBody(result); + }); ---- - -=== How to consume a message from a Camel CXF endpoint in POJO data format - -The Camel CXF endpoint consumer POJO data format is based on the -http://cxf.apache.org/docs/invokers.html[CXF invoker], so the -message header has a property with the name of -`CxfConstants.OPERATION_NAME` and the message body is a list of the SEI -method parameters. - -Consider the https://github.com/apache/camel/blob/main/components/camel-cxf/camel-cxf-soap/src/test/java/org/apache/camel/wsdl_first/PersonProcessor.java[PersonProcessor] example code: +For more dynamic implementation (more "CXF way"), we can use https://camel.apache.org/components/next/bean-component.html[Bean] invocation based on requested operation name: Review Comment: What is more dynamic about the more CXF way? ########## components/camel-cxf/camel-cxf-soap/src/main/docs/cxf-component.adoc: ########## @@ -576,10 +582,14 @@ Having simple java web service interface: ---- package org.apache.camel.component.cxf.soap.server; -@WebService(targetNamespace = "http://server.soap.cxf.component.camel.apache.org/", name = "EchoService") -public interface EchoService { +import jakarta.jws.WebService; + +@WebService(targetNamespace = "http://server.soap.cxf.component.camel.apache.org/", name = "TextService", serviceName = "TextService") +public interface TextService { - String echo(String text); + String upperCase(String text); + + String lowerCase(String text); Review Comment: ```suggestion @WebMethod String upperCase(String text); @WebMethod String lowerCase(String text); ``` Plus the WebMethod import ########## components/camel-cxf/camel-cxf-soap/src/main/docs/cxf-component.adoc: ########## @@ -567,7 +567,13 @@ and setDefaultBus properties from spring configuration file. == Examples -=== How to create a simple CXF service with POJO data format +=== How to consume a message from a Camel CXF endpoint in POJO data format + +The Camel CXF endpoint consumer POJO data format is based on the +http://cxf.apache.org/docs/invokers.html[CXF invoker], so the +message header has a property with the name of +`CxfConstants.OPERATION_NAME` and the message body is a list of the SEI +method parameters. Review Comment: ```suggestion operation parameters. ``` SEI is not necessarily wrong, but requires some knowledge that is not that important here. "operation parameters" is perhaps easier to understand. ########## components/camel-cxf/camel-cxf-soap/src/main/docs/cxf-component.adoc: ########## @@ -590,86 +600,50 @@ And implementation: package org.apache.camel.component.cxf.soap.server; -@WebService(name = "EchoService", serviceName = "EchoService", targetNamespace = "http://server.soap.cxf.component.camel.apache.org/") -public class EchoServiceImpl implements EchoService { +import jakarta.jws.WebService; + +@WebService(name = "TextService", serviceName = "TextService", targetNamespace = "http://server.soap.cxf.component.camel.apache.org/") +public class TextServiceImpl implements TextService { @Override - public String echo(String text) { - return text; + public String upperCase(String text) { + return text.toUpperCase(); } + @Override + public String lowerCase(String text) { + return text.toLowerCase(); + } } ----- Review Comment: Wouldn't if be better to move the impl. down to the "CXF way"? It is not needed for the Camel way, no? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
