将 CachedOutputStream 转换为字符串

问题描述 投票:0回答:1

将 CachedOutputStream 转换为字符串。
将camel从2.12升级到2.23后,我的路线出现问题,相同的代码相同的路线。

调用端点后的响应类型为

org.apache.camel.converter.stream.CachedOutputStream

我尝试将
CachedOutputStream
转换为字符串。

String body = exchange.getIn().getBody(String.class);
logger.info("FJA the string after caling endpoint: " + body);

我在 FJA 加强后使用 dk.bankconnect.hub.Util:

-0��phjA����/h`�FhI[����G<�����,�Z���f���=��Rϝ��s#���O��~#�G�t

如何将CachedOutputStream转换为字符串?

我尝试了很多不同的方法来避免响应以流的形式出现。然而,我没有成功。

这是我路线的一小段:

from("direct:sdc:webservice")
            .setProperty("webservice", constant(Boolean.TRUE))    
            .setProperty("duration", simple("Forwarding request to ${property.datacentral} datacentral"))
            .choice().when().simple("${property.Tracked} == true").bean(Util.class, "dura-tion").end()
            .bean(Util.class, "tracker")
            .bean(Util.class, "foer")
            .to(Util.getProperty("sdc.url"))
            .bean(Util.class, "efter")
            .convertBodyTo(Document.class)            
            .setProperty("duration", simple("Receiving response from ${proper-ty.datacentral} datacentral"))
            .choice().when().simple("${property.Tracked} == true").bean(Util.class, "dura-tion").end()
            .bean(Util.class, "tracker")
            .setProperty(SoapError.FAULT, xpath("/soapenv:Envelope/soapenv:Body/soapenv:Fault/faultstring/text()", String.class).namespace("soapenv", Namespace.SOAP))
            .end();

我的convertBodyTo失败了,因为它突然成为一个流。

apache-camel
1个回答
0
投票

好的,很短

调用端点后的响应类型为 org.apache.camel.converter.stream.CachedOutputStream 我尝试将 CachedOutputStream 转换为字符串。

字符串主体=exchange.getIn().getBody(String.class);

这不是一个可读的字符串,而是很多特殊字符。

弗兰克:-)

© www.soinside.com 2019 - 2024. All rights reserved.