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 2008/09/14 18:05:29 UTC
svn commit: r695245 - in /activemq/camel/trunk/components/camel-cxf/src:
main/java/org/apache/camel/component/cxf/
main/java/org/apache/camel/component/cxf/converter/
test/java/org/apache/camel/component/cxf/
test/resources/org/apache/camel/component/cxf/
Author: ningjiang
Date: Sun Sep 14 09:05:28 2008
New Revision: 695245
URL: http://svn.apache.org/viewvc?rev=695245&view=rev
Log:
CAMEL-900 added a SOAPMessage to String convertor
Added:
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSoapMessageProviderConvertStringTest.java (with props)
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SoapMessageProviderConvertString.xml (with props)
Modified:
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CamelInvoker.java
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfMessage.java
activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfWsdlFirstTest.java
activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/SoapTargetBean.java
activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SoapMessageProviderContext.xml
Modified: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CamelInvoker.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CamelInvoker.java?rev=695245&r1=695244&r2=695245&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CamelInvoker.java (original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CamelInvoker.java Sun Sep 14 09:05:28 2008
@@ -178,10 +178,13 @@
Object result = null;
if (cxfExchange.isFailed()) {
- Exception ex = (Exception)cxfExchange.getFault().getBody();
+ Throwable ex = (Throwable)cxfExchange.getFault().getBody();
if (ex instanceof Fault) {
throw (Fault)ex;
} else {
+ if (ex == null) {
+ ex = cxfExchange.getException();
+ }
throw new Fault(ex);
}
} else {
Modified: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfMessage.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfMessage.java?rev=695245&r1=695244&r2=695245&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfMessage.java (original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfMessage.java Sun Sep 14 09:05:28 2008
@@ -82,7 +82,7 @@
public void setMessage(Message cxfMessage) {
this.cxfMessage = cxfMessage;
}
-
+
@Override
public CxfMessage newInstance() {
return new CxfMessage();
Modified: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java?rev=695245&r1=695244&r2=695245&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java (original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java Sun Sep 14 09:05:28 2008
@@ -16,10 +16,17 @@
*/
package org.apache.camel.component.cxf.converter;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import java.util.Map;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+
import org.apache.camel.Converter;
import org.apache.camel.Endpoint;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.cxf.message.MessageContentsList;
@@ -31,6 +38,7 @@
*/
@Converter
public final class CxfConverter {
+ private static final Log LOG = LogFactory.getLog(CxfConverter.class);
private CxfConverter() {
// Helper class
@@ -44,6 +52,7 @@
return list.toArray();
}
+ @Converter
public static MessageContentsList toMessageContentsList(final Object[] array) {
if (array != null) {
return new MessageContentsList(array);
@@ -52,6 +61,17 @@
}
}
+ @Converter
+ public static String soapMessageToString(final SOAPMessage soapMessage) {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try {
+ soapMessage.writeTo(baos);
+ } catch (Exception e) {
+ LOG.error("Get the exception when converting the SOAPMessage into String, the exception is " + e);
+ }
+ return baos.toString();
+ }
+
Added: activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSoapMessageProviderConvertStringTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSoapMessageProviderConvertStringTest.java?rev=695245&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSoapMessageProviderConvertStringTest.java (added)
+++ activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSoapMessageProviderConvertStringTest.java Sun Sep 14 09:05:28 2008
@@ -0,0 +1,41 @@
+/**
+ * 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.component.cxf;
+
+import java.lang.reflect.UndeclaredThrowableException;
+import java.net.URL;
+
+import javax.xml.namespace.QName;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.spring.processor.SpringTestHelper;
+import org.apache.hello_world_soap_http.Greeter;
+import org.apache.hello_world_soap_http.SOAPService;
+
+
+public class CxfSoapMessageProviderConvertStringTest extends CxfSoapMessageProviderTest {
+
+ @Override
+ protected CamelContext createCamelContext() throws Exception {
+ return SpringTestHelper.createSpringCamelContext(this, "org/apache/camel/component/cxf/SoapMessageProviderConvertString.xml");
+ }
+
+
+
+
+}
Propchange: activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSoapMessageProviderConvertStringTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfSoapMessageProviderConvertStringTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfWsdlFirstTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfWsdlFirstTest.java?rev=695245&r1=695244&r2=695245&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfWsdlFirstTest.java (original)
+++ activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfWsdlFirstTest.java Sun Sep 14 09:05:28 2008
@@ -36,6 +36,7 @@
import org.apache.cxf.endpoint.ServerImpl;
import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.cxf.jaxws.EndpointImpl;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class CxfWsdlFirstTest extends SpringTestSupport {
@@ -62,7 +63,8 @@
protected void startService() {
Object implementor = new PersonImpl();
String address = "http://localhost:9000/PersonService/";
- Endpoint.publish(address, implementor);
+ EndpointImpl endpoint = (EndpointImpl) Endpoint.publish(address, implementor);
+ server = endpoint.getServer();
}
@Override
Modified: activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/SoapTargetBean.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/SoapTargetBean.java?rev=695245&r1=695244&r2=695245&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/SoapTargetBean.java (original)
+++ activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/SoapTargetBean.java Sun Sep 14 09:05:28 2008
@@ -46,7 +46,17 @@
}
}
- public SOAPMessage invoke(SOAPMessage request) {
+ public SOAPMessage invokeString(String request) {
+ SOAPMessage response = null;
+ if (request.indexOf("sayHi") > 0) {
+ response = sayHiResponse;
+ } else {
+ response = greetMeResponse;
+ }
+ return response;
+ }
+
+ public SOAPMessage invokeSoapMessage(SOAPMessage request) {
SOAPMessage response = null;
try {
SOAPBody body = request.getSOAPBody();
Modified: activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SoapMessageProviderContext.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SoapMessageProviderContext.xml?rev=695245&r1=695244&r2=695245&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SoapMessageProviderContext.xml (original)
+++ activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SoapMessageProviderContext.xml Sun Sep 14 09:05:28 2008
@@ -49,7 +49,7 @@
<route>
<from uri="cxf:bean:soapMessageEndpoint"/>
<process ref="parameterProcessor" />
- <to uri="bean:targetBean?methodName=invoke"/>
+ <to uri="bean:targetBean?methodName=invokeSoapMessage"/>
</route>
</camelContext>
Added: activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SoapMessageProviderConvertString.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SoapMessageProviderConvertString.xml?rev=695245&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SoapMessageProviderConvertString.xml (added)
+++ activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SoapMessageProviderConvertString.xml Sun Sep 14 09:05:28 2008
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ 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-2.5.xsd
+ http://activemq.apache.org/camel/schema/cxfEndpoint
+ http://activemq.apache.org/camel/schema/cxf/cxfEndpoint.xsd
+ http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd
+ ">
+
+
+ <!--
+ If you want to run this example in Tomcat container which need to used servlet transoprt,
+ please repalce the cxf-extension-http-jetty.xml with cxf-servlet.xml
+ -->
+
+ <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-extension-http-jetty.xml" />
+
+ <bean id = "targetBean" class="org.apache.camel.component.cxf.SoapTargetBean" />
+ <bean id = "parameterProcessor" class="org.apache.camel.component.cxf.ParameterProcessor"/>
+
+ <cxf:cxfEndpoint id="soapMessageEndpoint"
+ serviceClass="org.apache.camel.component.cxf.SoapMessageProvider"
+ address="http://localhost:9003/SoapContext/SoapProviderPort"
+ />
+
+
+ <camelContext id="test_context" xmlns="http://activemq.apache.org/camel/schema/spring">
+ <route>
+ <from uri="cxf:bean:soapMessageEndpoint"/>
+ <process ref="parameterProcessor" />
+ <convertBodyTo type="java.lang.String"/>
+ <to uri="bean:targetBean?methodName=invokeString"/>
+ </route>
+ </camelContext>
+
+</beans>
Propchange: activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SoapMessageProviderConvertString.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SoapMessageProviderConvertString.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: activemq/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SoapMessageProviderConvertString.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml