[
https://issues.apache.org/activemq/browse/CAMEL-1431?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=50603#action_50603
]
Charles Moulliard edited comment on CAMEL-1431 at 3/17/09 8:36 AM:
-------------------------------------------------------------------
I will test what you propose.
By the way, Claus in its tutorial does not return anything
(http://cwiki.apache.org/CAMEL/tutorial-example-reportincident-part5.html)
{code}
public void configure() throws Exception {
// webservice response for OK
OutputReportIncident OK = new OutputReportIncident();
OK.setCode("0");
// endpoint to our CXF webservice
String cxfEndpoint =
"cxf://http://localhost:8080/part-five/webservices/incident"
+
"?serviceClass=org.apache.camel.example.reportincident.ReportIncidentEndpoint"
+ "&wsdlURL=report_incident.wsdl";
// first part from the webservice -> file backup
from(cxfEndpoint)
// we need to convert the CXF payload to InputReportIncident that
FilenameGenerator and velocity expects
.convertBodyTo(InputReportIncident.class)
// then set the file name using the FilenameGenerator bean
.setHeader(FileComponent.HEADER_FILE_NAME,
BeanLanguage.bean(FilenameGenerator.class, "generateFilename"))
// and create the mail body using velocity templating
.to("velocity:MailBody.vm")
// and store the file
.to("file://target/subfolder")
// return OK as response
.transform(constant(OK));
// second part from the file backup -> send email
from("file://target/subfolder")
// set the subject of the email
.setHeader("subject", constant("new incident reported"))
// send the email
.to("smtp://some...@localhost?password=secret&[email protected]");
}
{code}
was (Author: cmoulliard):
I will test what you propose.
By the way, Claus in its tutorial does not return anything
(http://cwiki.apache.org/CAMEL/tutorial-example-reportincident-part5.html)
{code}
public void configure() throws Exception {
// webservice response for OK
OutputReportIncident OK = new OutputReportIncident();
OK.setCode("0");
// endpoint to our CXF webservice
String cxfEndpoint =
"cxf://http://localhost:8080/part-five/webservices/incident"
+
"?serviceClass=org.apache.camel.example.reportincident.ReportIncidentEndpoint"
+ "&wsdlURL=report_incident.wsdl";
// first part from the webservice -> file backup
from(cxfEndpoint)
// we need to convert the CXF payload to InputReportIncident that
FilenameGenerator and velocity expects
.convertBodyTo(InputReportIncident.class)
// then set the file name using the FilenameGenerator bean
.setHeader(FileComponent.HEADER_FILE_NAME,
BeanLanguage.bean(FilenameGenerator.class, "generateFilename"))
// and create the mail body using velocity templating
.to("velocity:MailBody.vm")
// and store the file
.to("file://target/subfolder")
// return OK as response
.transform(constant(OK));
// second part from the file backup -> send email
from("file://target/subfolder")
// set the subject of the email
.setHeader("subject", constant("new incident reported"))
// send the email
.to("smtp://some...@localhost?password=secret&[email protected]");
}
'code}
> camel-cxf and spring DSL does not work very well
> ------------------------------------------------
>
> Key: CAMEL-1431
> URL: https://issues.apache.org/activemq/browse/CAMEL-1431
> Project: Apache Camel
> Issue Type: Sub-task
> Components: camel-cxf
> Affects Versions: 2.0-M1
> Reporter: Charles Moulliard
> Assignee: Willem Jiang
>
> Hi,
> Camel-cxf and camel works very well when the routing is defined like this :
> {code}
> public class ReportIncidentRoutes extends RouteBuilder {
> public void configure() throws Exception {
> // webservice response for OK
> OutputReportIncident OK = new OutputReportIncident();
> OK.setCode("0");
> // endpoint to our CXF webservice
> String cxfEndpoint =
> "cxf://http://localhost:8080/camel-example/incident"
> +
> "?serviceClass=org.apache.camel.example.reportincident.ReportIncidentEndpoint"
> + "&wsdlURL=wsdl/report_incident.wsdl";
> // first part from the webservice -> file backup
> from(cxfEndpoint)
> // we need to convert the CXF payload to InputReportIncident that
> FilenameGenerator and velocity expects
> .convertBodyTo(InputReportIncident.class)
> // return OK as response
> .transform(constant(OK));
> }
> @ContextConfiguration
> public class ReportIncidentRoutesTest extends
> AbstractJUnit4SpringContextTests {
>
> private static final transient Log LOG =
> LogFactory.getLog(ReportIncidentRoutesTest.class);
>
> @Autowired
> protected CamelContext camelContext;
> // should be the same address as we have in our route
> private final static String ADDRESS =
> "http://localhost:8080/camel-example/incident";
> //private final static QName endpointName = new
> QName("http://reportincident.example.camel.apache.org",
> "ReportIncidentEndpoint");
> protected static ReportIncidentEndpoint createCXFClient() {
> // we use CXF to create a client for us as its easier than JAXWS and
> works
> JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
> factory.setServiceClass(ReportIncidentEndpoint.class);
> factory.setAddress(ADDRESS);
> //factory.setEndpointName(endpointName);
> return (ReportIncidentEndpoint) factory.create();
> }
> @Test
> public void testRendportIncident() throws Exception {
>
> assertNotNull(camelContext);
> // create input parameter
> InputReportIncident input = new InputReportIncident();
> input.setIncidentId("123");
> input.setIncidentDate("2008-08-18");
> input.setGivenName("Claus");
> input.setFamilyName("Ibsen");
> input.setSummary("Bla");
> input.setDetails("Bla bla");
> input.setEmail("[email protected]");
> input.setPhone("0045 2962 7576");
> // create the webservice client and send the request
> ReportIncidentEndpoint client = createCXFClient();
> OutputReportIncident out = client.reportIncident(input);
> // assert we got a OK back
> assertEquals("0", out.getCode());
> }
>
> }
> {code}
> but not when the routing is defined in spring DSL
> {code}
> <?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:camel="http://camel.apache.org/schema/spring"
> xmlns:cxf="http://camel.apache.org/schema/cxf"
> xsi:schemaLocation=" http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
> http://camel.apache.org/schema/osgi
> http://camel.apache.org/schema/osgi/camel-osgi.xsd
> http://camel.apache.org/schema/spring
> http://camel.apache.org/schema/spring/camel-spring.xsd
> http://camel.apache.org/schema/cxf
> http://camel.apache.org/schema/cxf/camel-cxf.xsd">
>
> <bean id="webService"
> class="org.apache.camel.example.reportincident.beans.WebService" />
>
> <bean id="OK"
> class="org.apache.camel.example.reportincident.OutputReportIncident">
> <property name="code" value="0"/>
> </bean>
>
> <!-- webservice endpoint -->
> <cxf:cxfEndpoint id="reportIncident"
> address="http://localhost:8080/camel-example/incident"
> wsdlURL="wsdl/report_incident.wsdl"
>
> serviceClass="org.apache.camel.example.reportincident.ReportIncidentEndpoint"
> xmlns:s="http://reportincident.example.camel.apache.org">
> </cxf:cxfEndpoint>
>
> <camelContext trace="true" xmlns="http://camel.apache.org/schema/osgi">
>
> <camel:package>org.apache.camel.example.reportincident.routing</camel:package>
>
> <!-- CXF route -->
> <camel:route>
> <camel:from uri="cxf:bean:reportIncident" />
> <camel:convertBodyTo
> type="org.apache.camel.example.reportincident.InputReportIncident" />
> <camel:transform>
> <camel:method bean="OK" method="code"/>
> </camel:transform>
> </camel:route>
>
>
> </camelContext>
> </beans>
> {code}
> In debugging mode, I see that the outputreportincident object is null when we
> call the method declared in the web service. So something happens with Spring
> & Cxf.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.