camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem Jiang <willem.ji...@gmail.com>
Subject Re: Trying to consume SOAP WS with UTF-8 content, getting "Invalid UTF-8 middle byte 0x3c"
Date Thu, 02 Jan 2014 02:04:10 GMT
Hi,

You can set the Content-Type through the request message context like this
public void process(final Exchange exchange) {
                Map<String, Object> requestContext = new HashMap<String,
Object>();
                requestContext.put("Content-Type", "application/soap+xml;charset=UTF-8");
                exchange.getIn().setHeader(“RequestContext" , requestContext);
                
                exchange.getIn().setBody("<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
                                 + "<soap:Body><ns1:echo xmlns:ns1=\"http://cxf.component.camel.apache.org/\">"
                                 + "<arg0 xmlns=\"http://cxf.component.camel.apache.org/\">hello
world</arg0>"
                                 + "</ns1:echo></soap:Body></soap:Envelope>");
            }

--  
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com(http://willemjiang.blogspot.com/) (English)
http://jnn.iteye.com(http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem



On January 1, 2014 at 10:25:30 PM, jannecamel (jannesm@iki.fi) wrote:
>  
> I dug a little deeper. I activated cxf component's loggingFeatureEnabled  
> property. Seems that the response from the WS is encoded with  
> ISO-8859-1:
>  
> request:
>  
> 014-01-01 16:10:01,055 | INFO | ler-ura_Worker-1 | UraPort  
> | 132 - org.apache.cxf.cxf-api - 2.6.8 | Outbound Message
> ---------------------------
> ID: 1
> Address: http://localhost:8080/integraatiot-ws-1.0-SNAPSHOT/UraImpl  
> Content-Type: text/xml
> Headers: {Accept=[*/*],
> breadcrumbId=[ID-vagrant-lubuntu-quantic-42829-1388585068316-7-3],  
> fireTime=[Wed Jan 01 16:10:00 EET 2014], jobDetail=[JobDetail  
> 'DEFAULT.quartz-endpoint82': jobClass:
> 'org.apache.camel.component.quartz.CamelJob isStateful:  
> false isVolatile:
> false isDurable: false requestsRecovers: false],
> jobInstance=[org.apache.camel.component.quartz.CamelJob@3d722847],  
> jobRunTime=[-1], mergedJobDataMap=[org.quartz.JobDataMap@509f17b6],  
> nextFireTime=[Wed Jan 01 16:11:00 EET 2014], refireCount=[0],  
> scheduledFireTime=[Wed Jan 01 16:10:00 EET 2014],
> scheduler=[org.quartz.impl.StdScheduler@236312f7], trigger=[Trigger  
> 'Camel.uraDelegoinnitJob': triggerClass: 'org.quartz.CronTrigger  
> isVolatile: false calendar: 'null' misfireInstruction: 0  
> nextFireTime: Wed
> Jan 01 16:11:00 EET 2014], triggerGroup=[Camel],
> triggerName=[uraDelegoinnitJob]}
> Payload:  
> > xmlns:ns3="http://eura2014.fi/ura/xsd/1.0">
>  
> ...
>  
>  
>  
>  
> response:
>  
> 2014-01-01 16:15:01,019 | INFO | ault-workqueue-1 | UraPort  
> | 132 - org.apache.cxf.cxf-api - 2.6.8 | Inbound Message
> ----------------------------
> ID: 6
> Response-Code: 200
> Encoding: ISO-8859-1
> Content-Type: text/xml;charset=ISO-8859-1
> Headers: {Content-Length=[2306], content-type=[text/xml;charset=ISO-8859-1],  
> Date=[Wed, 01 Jan 2014 14:15:01 GMT], Server=[Apache-Coyote/1.1]}  
> Payload: > xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">somfoostuff....kuvaus
 
> jossa viimeinen merkki on skandiÄ
>  
> When I test the same WS with SoapUI, I get the response in UTF-8.  
>  
> Date Wed, 01 Jan 2014 12:47:22 GMT
> Content-Length 2306
> #status# HTTP/1.1 200 OK
> Content-Type application/soap+xml;charset=UTF-8
> Server Apache-Coyote/1.1
>  
> SoapUI seems to have preferences for "request properties / encoding"  
> and
> this results in http header
> "Content-Type:application/soap+xml;charset=UTF-8". And  
> this changes the
> actual WS to return UTF-8 instead of ISO-8859-1.
>  
> Can I configure camel / cxf component to request for UTF-8 encoding  
> as well?
> I could not find a quick param for that at
> http://camel.apache.org/cxf.html#CXF-Thedescriptionsofthedataformats  
>  
>  
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/Trying-to-consume-SOAP-WS-with-UTF-8-content-getting-Invalid-UTF-8-middle-byte-0x3c-tp5745394p5745396.html
 
> Sent from the Camel - Users mailing list archive at Nabble.com.  
>  


Mime
View raw message