Return-Path: X-Original-To: apmail-camel-dev-archive@www.apache.org Delivered-To: apmail-camel-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 35A8D9FED for ; Thu, 14 Jun 2012 07:37:41 +0000 (UTC) Received: (qmail 2444 invoked by uid 500); 14 Jun 2012 07:37:40 -0000 Delivered-To: apmail-camel-dev-archive@camel.apache.org Received: (qmail 2102 invoked by uid 500); 14 Jun 2012 07:37:35 -0000 Mailing-List: contact dev-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list dev@camel.apache.org Received: (qmail 2060 invoked by uid 99); 14 Jun 2012 07:37:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Jun 2012 07:37:33 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of willem.jiang@gmail.com designates 209.85.160.45 as permitted sender) Received: from [209.85.160.45] (HELO mail-pb0-f45.google.com) (209.85.160.45) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Jun 2012 07:37:29 +0000 Received: by pbbro12 with SMTP id ro12so3653425pbb.32 for ; Thu, 14 Jun 2012 00:37:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=3bP6VqhVcCyTbJRvCBy3FCxeBTWYNeMPsuVhGflp9uw=; b=vhMbGz+NI8n/vFhEWr8QbYeNzmBoDWp7ZvcvL66CVw4K2GlSJEsZO5B1tBdEUVdMlm 7AEI9uCWvnrIxMAa1F3/Ev/vy+IlJfRzbnQXFUonCbCkvazaKzye2kbeel+GGI0bytWc cbfKXbFKFzL7AKlWvTdHSBDaj7IkcxHiCPckKH+0wX8DUVJEGAaPe43ORwzxnG+5Mj0G eVxfY6r0DYVgXSUTNkoKQfsUvArug2Kwf6favjdtjU8MzE8p/YEbHwZeUVjlhLSOf1wv JKvZ0mr9YBxJa85swX5KLbI42s/NGoFEe+MimgHAC/2OP6fzlLLQ8eRqEvfaw+DxHFKN mVTg== Received: by 10.68.136.68 with SMTP id py4mr4871562pbb.151.1339659428469; Thu, 14 Jun 2012 00:37:08 -0700 (PDT) Received: from [192.168.0.158] ([125.34.9.84]) by mx.google.com with ESMTPS id na10sm2204447pbc.23.2012.06.14.00.37.04 (version=SSLv3 cipher=OTHER); Thu, 14 Jun 2012 00:37:07 -0700 (PDT) Message-ID: <4FD9949C.3050905@gmail.com> Date: Thu, 14 Jun 2012 15:37:00 +0800 From: Willem Jiang User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: dev@camel.apache.org Subject: Re: svn commit: r1349901 - in /camel/trunk/components/camel-cxf/src: main/java/org/apache/camel/component/cxf/converter/ test/java/org/apache/camel/component/cxf/ test/resources/org/apache/camel/component/cxf/ References: <20120613152036.24A71238899C@eris.apache.org> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Hi Claus, Thanks for the review, I just update the code by removing the try ... catch codes. On Thu Jun 14 11:34:45 2012, Claus Ibsen wrote: > Hi > > In the converter code, you do a try .. catch and then swallow the caused > exception. > You should not do this, but throw the exception. And remove the logging. > > > On Wed, Jun 13, 2012 at 5:20 PM, wrote: > >> Author: ningjiang >> Date: Wed Jun 13 15:20:35 2012 >> New Revision: 1349901 >> >> URL: http://svn.apache.org/viewvc?rev=1349901&view=rev >> Log: >> CAMEL-5365 Added SOAPMessage to InputStream coverter >> >> Added: >> >> camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SoapMessageProviderStreamContext.xml >> Modified: >> >> camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java >> >> camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/SoapTargetBean.java >> >> Modified: >> camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java >> URL: >> http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java?rev=1349901&r1=1349900&r2=1349901&view=diff >> >> ============================================================================== >> --- >> camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java >> (original) >> +++ >> camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfConverter.java >> Wed Jun 13 15:20:35 2012 >> @@ -28,6 +28,7 @@ import org.apache.camel.Exchange; >> import org.apache.camel.FallbackConverter; >> import org.apache.camel.TypeConverter; >> import org.apache.camel.component.cxf.DataFormat; >> +import org.apache.camel.converter.stream.CachedOutputStream; >> import org.apache.camel.spi.TypeConverterRegistry; >> import org.apache.cxf.message.MessageContentsList; >> import org.slf4j.Logger; >> @@ -89,6 +90,19 @@ public final class CxfConverter { >> } >> >> @Converter >> + public static InputStream soapMessageToInputStream(final SOAPMessage >> soapMessage, Exchange exchange) { >> + CachedOutputStream cos = new CachedOutputStream(exchange); >> + InputStream in = null; >> + try { >> + soapMessage.writeTo(cos); >> + in = cos.getInputStream(); >> + } catch (Exception e) { >> + LOG.error("Get the exception when converting the SOAPMessage >> into InputStream, the exception is " + e); >> + } >> + return in; >> + } >> + >> + @Converter >> public static DataFormat toDataFormat(final String name) { >> return DataFormat.valueOf(name.toUpperCase()); >> } >> >> Modified: >> camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/SoapTargetBean.java >> URL: >> http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/SoapTargetBean.java?rev=1349901&r1=1349900&r2=1349901&view=diff >> >> ============================================================================== >> --- >> camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/SoapTargetBean.java >> (original) >> +++ >> camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/SoapTargetBean.java >> Wed Jun 13 15:20:35 2012 >> @@ -23,11 +23,14 @@ import javax.xml.soap.MessageFactory; >> import javax.xml.soap.SOAPBody; >> import javax.xml.soap.SOAPMessage; >> >> +import org.w3c.dom.Document; >> import org.w3c.dom.Node; >> >> +import org.apache.cxf.helpers.XMLUtils; >> + >> public class SoapTargetBean { >> - private static QName sayHi = new QName(" >> http://apache.org/hello_world_soap_http", "sayHi"); >> - private static QName greetMe = new QName(" >> http://apache.org/hello_world_soap_http", "greetMe"); >> + private static QName sayHi = new QName(" >> http://apache.org/hello_world_soap_http/types", "sayHi"); >> + private static QName greetMe = new QName(" >> http://apache.org/hello_world_soap_http/types", "greetMe"); >> private SOAPMessage sayHiResponse; >> private SOAPMessage greetMeResponse; >> >> @@ -76,4 +79,21 @@ public class SoapTargetBean { >> return response; >> } >> >> + //Simulates a stream based processor or producer (e.g., file EP) >> + public SOAPMessage invokeStream(InputStream in) { >> + SOAPMessage response = null; >> + try { >> + Document doc = XMLUtils.parse(in); >> + if (doc.getElementsByTagNameNS(greetMe.getNamespaceURI(), >> + >> sayHi.getLocalPart()).getLength() == 1) { >> + response = sayHiResponse; >> + } else if >> (doc.getElementsByTagNameNS(greetMe.getNamespaceURI(), >> + >> greetMe.getLocalPart()).getLength() == 1) { >> + response = greetMeResponse; >> + } >> + } catch (Exception ex) { >> + ex.printStackTrace(); >> + } >> + return response; >> + } >> } >> >> Added: >> camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SoapMessageProviderStreamContext.xml >> URL: >> http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SoapMessageProviderStreamContext.xml?rev=1349901&view=auto >> >> ============================================================================== >> --- >> camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SoapMessageProviderStreamContext.xml >> (added) >> +++ >> camel/trunk/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/SoapMessageProviderStreamContext.xml >> Wed Jun 13 15:20:35 2012 >> @@ -0,0 +1,52 @@ >> + >> + >> +> + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >> + xmlns:cxf="http://camel.apache.org/schema/cxf" >> + xsi:schemaLocation=" >> + http://www.springframework.org/schema/beans >> + http://www.springframework.org/schema/beans/spring-beans.xsd >> + http://camel.apache.org/schema/cxf >> http://camel.apache.org/schema/cxf/camel-cxf.xsd >> + http://camel.apache.org/schema/spring >> http://camel.apache.org/schema/spring/camel-spring.xsd >> + "> >> + >> +> class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/> >> + >> + >> + >> + >> + >> +> class="org.apache.camel.component.cxf.SoapTargetBean" /> >> + >> +> + >> serviceClass="org.apache.camel.component.cxf.SoapMessageProvider" >> + address="http://localhost: >> ${CXFTestSupport.port1}/CxfSoapMessageProviderTest/SoapContext/SoapProviderPort"> >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> + >> >> >> > > -- Willem ---------------------------------- FuseSource Web: http://www.fusesource.com Blog: http://willemjiang.blogspot.com (English) http://jnn.javaeye.com (Chinese) Twitter: willemjiang Weibo: willemjiang