You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2011/02/24 15:37:21 UTC
svn commit: r1074164 - in
/camel/trunk/examples/camel-example-cxf-tomcat/src/main:
java/org/apache/camel/example/cxf/CamelRouteClient.java
resources/camel-config.xml webapp/WEB-INF/web.xml
Author: ningjiang
Date: Thu Feb 24 14:37:21 2011
New Revision: 1074164
URL: http://svn.apache.org/viewvc?rev=1074164&view=rev
Log:
CAMEL-3702 Added client code for testing
Added:
camel/trunk/examples/camel-example-cxf-tomcat/src/main/java/org/apache/camel/example/cxf/CamelRouteClient.java (with props)
Modified:
camel/trunk/examples/camel-example-cxf-tomcat/src/main/resources/camel-config.xml
camel/trunk/examples/camel-example-cxf-tomcat/src/main/webapp/WEB-INF/web.xml
Added: camel/trunk/examples/camel-example-cxf-tomcat/src/main/java/org/apache/camel/example/cxf/CamelRouteClient.java
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf-tomcat/src/main/java/org/apache/camel/example/cxf/CamelRouteClient.java?rev=1074164&view=auto
==============================================================================
--- camel/trunk/examples/camel-example-cxf-tomcat/src/main/java/org/apache/camel/example/cxf/CamelRouteClient.java (added)
+++ camel/trunk/examples/camel-example-cxf-tomcat/src/main/java/org/apache/camel/example/cxf/CamelRouteClient.java Thu Feb 24 14:37:21 2011
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.example.cxf;
+
+import org.apache.camel.example.cxf.incident.IncidentService;
+import org.apache.camel.example.cxf.incident.InputReportIncident;
+import org.apache.camel.example.cxf.incident.InputStatusIncident;
+import org.apache.camel.example.cxf.incident.OutputReportIncident;
+import org.apache.camel.example.cxf.incident.OutputStatusIncident;
+import org.apache.cxf.frontend.ClientProxyFactoryBean;
+
+
+public class CamelRouteClient {
+ // You may need to change the URL according to the Camel version
+ private static final String URL = "http://localhost:8080/camel-example-cxf-tomcat-2.7-SNAPSHOT/webservices/incident";
+
+ protected static IncidentService createCXFClient() {
+ // we use CXF to create a client for us as its easier than JAXWS and works
+ ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
+ factory.setServiceClass(IncidentService.class);
+ factory.setAddress(URL);
+ return (IncidentService) factory.create();
+ }
+
+ public static void main(String[] args) throws Exception {
+ CamelRouteClient client = new CamelRouteClient();
+ client.runTest();
+ }
+
+ protected void runTest() throws Exception {
+
+ // 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("davsclaus@apache.org");
+ input.setPhone("0045 2962 7576");
+
+ // create the webservice client and send the request
+ IncidentService client = createCXFClient();
+ OutputReportIncident out = client.reportIncident(input);
+ System.out.println(out.getCode());
+ InputStatusIncident inStatus = new InputStatusIncident();
+ inStatus.setIncidentId("456");
+ OutputStatusIncident outStatus = client.statusIncident(inStatus);
+ System.out.println(outStatus.getStatus());
+
+ }
+
+}
Propchange: camel/trunk/examples/camel-example-cxf-tomcat/src/main/java/org/apache/camel/example/cxf/CamelRouteClient.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: camel/trunk/examples/camel-example-cxf-tomcat/src/main/java/org/apache/camel/example/cxf/CamelRouteClient.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: camel/trunk/examples/camel-example-cxf-tomcat/src/main/resources/camel-config.xml
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf-tomcat/src/main/resources/camel-config.xml?rev=1074164&r1=1074163&r2=1074164&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-cxf-tomcat/src/main/resources/camel-config.xml (original)
+++ camel/trunk/examples/camel-example-cxf-tomcat/src/main/resources/camel-config.xml Thu Feb 24 14:37:21 2011
@@ -31,10 +31,12 @@
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
<!-- use the CXF servlet -->
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
-
+
+ <bean id="myRoutes" class="org.apache.camel.example.cxf.CamelRoute"/>
+
<camelContext xmlns="http://camel.apache.org/schema/spring">
<!-- let Camel automatic find the route in this java package -->
- <package>org.apache.camel.example.cxf</package>
+ <routeBuilder ref="myRoutes"/>
</camelContext>
</beans>
Modified: camel/trunk/examples/camel-example-cxf-tomcat/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf-tomcat/src/main/webapp/WEB-INF/web.xml?rev=1074164&r1=1074163&r2=1074164&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-cxf-tomcat/src/main/webapp/WEB-INF/web.xml (original)
+++ camel/trunk/examples/camel-example-cxf-tomcat/src/main/webapp/WEB-INF/web.xml Thu Feb 24 14:37:21 2011
@@ -39,6 +39,10 @@
<servlet-name>CXFServlet</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<load-on-startup>1</load-on-startup>
+ <!-- If you want to leverage the Servlet3's async feature in Tomcat,
+ please enable this feature
+ <async-supported>true</async-supported>
+ -->
</servlet>
<!-- all our webservices are mapped under this URI pattern -->