0

我有一个由 http 请求(POST,servlet 端点)触发的路由,使用速度将数据转换为 SOAP Web 服务请求,然后使用 http 将其发布到 Web 服务。然后我试图从中解析响应,但我在响应中得到二进制数据。但是 SOAPUI 显示正确的数据。

想法?

from("servlet:///cancelCode?servletName=CamelServlet")
.to("velocity:classpath:cancelCode.vm")
.setHeader(Exchange.HTTP_METHOD, constant("POST"))
.to(inteleOrderServiceEndpoint)

控制台中的响应:

2012-09-19 13:22:11 DEBUG [header:] << "HTTP/1.1 200 OK[\r][\n]"
2012-09-19 13:22:11 DEBUG [header:] << "HTTP/1.1 200 OK[\r][\n]"
2012-09-19 13:22:11 DEBUG [header:] << "Content-Type: text/xml; charset=utf-8[\r][\n]"
2012-09-19 13:22:11 DEBUG [header:] << "Content-Encoding: gzip[\r][\n]"
2012-09-19 13:22:11 DEBUG [header:] << "Transfer-Encoding: chunked[\r][\n]"
2012-09-19 13:22:11 DEBUG [header:] << "Server: Jetty(6.1.x)[\r][\n]"
2012-09-19 13:22:11 DEBUG [header:] << "[\r][\n]"
2012-09-19 13:22:11 DEBUG [content:] << "1"
2012-09-19 13:22:11 DEBUG [content:] << "0"
2012-09-19 13:22:11 DEBUG [content:] << "0"
2012-09-19 13:22:11 DEBUG [content:] << "[\r]"
2012-09-19 13:22:11 DEBUG [content:] << "[\n]"
2012-09-19 13:22:11 DEBUG [content:] << "[0x1f][0x8b][0x8][0x0][0x0][0x0][0x0][0x0][0x0][0x0][0x8d][0x92]]j[0xc3]0[0x10][0x84][0xdf]{[\n]"
2012-09-19 13:22:11 DEBUG [content:] << "[0xe3][0x3]hq[0xff]k\A[0xeb][0x98][0xb6][0x10][0xf2][0x90][0x1b][0xa8][0xf2][0xd2][0x14]$[0xad][0xd1][0xca][0xa1][0xb9]}[0xe5]Dn[0xed]bJ[0xde][0xa4][0x99][0xf9][0x16][0xcd][0xa2][0x8a]Iu[0xe8][0xf6]e[0xe3][0xf6]h[0xa8][0xc3][0xec][0xcb][0x1a][0xc7]e[0x92][0x1f][0xf3]][0x8]][0x9][0xc0]z[0x87]V[0xb1][0x88][0xee]`[0x9][0xf2][0x1f]0[0x1c][0x0][0x13][0x7]y"[0xb5]r?[0x14][0xb6]Z8[0xc][0x9a][0xac][0x8]h[0xd0][0x91][0x17][0x8e] &4[0x1a]M-z[0xe4][0x8e][0x1c][0xe3][0x84]-[0xce][0x86]9[0xa8][0xd0]s./[0xb2],[0xab][0xc6][0x1a][0xaf][0xa8][0xe2]X[0x98][0x8b][0xcf][0xd4][0x1e][0x8e][0xca] [0xc6][0x1][0xe5]iH[0x1d][0x87]l[0xd3][0xb][0xb6]Da[0x8c],[0xa6]z3[0xf5]S[0xa4](u[0xcf][0x81],[0xfa][0xb7][0x95]|[0xa1][0x83]jU[0x5][0xf5][0x5][0x8a][0xd1]*[0xb3][0xe9][0xed];zY\^][0xdf][0xdc][0xde][0xdd]?$tf.[0xc1][0xc7][0xde][0xb2]~[0xda][0xd4][0xcd]z[0xdd][0xac]F[0xec]$O:[0xc0]%[0x16][0xdc][0xf9]"*[0x98][0xaf][0xef][0xf7]>~[0x15][0xf9][\r][0xd4][0xe9][0x80][0xdd]=[0x2][0x0][0x0]"
2012-09-19 13:22:11 DEBUG [content:] << "[\r]"
2012-09-19 13:22:11 DEBUG [content:] << "[\n]"
2012-09-19 13:22:11 DEBUG [content:] << "0"
2012-09-19 13:22:11 DEBUG [content:] << "[\r]"
2012-09-19 13:22:11 DEBUG [content:] << "[\n]"
2012-09-19 13:22:11 DEBUG [content:] << "[\r]"
2012-09-19 13:22:11 DEBUG [content:] << "[\n]"
2012-09-19 13:22:11 DEBUG [header:] << "[\r][\n]"
4

1 回答 1

2

内容是 gzip 编码的(例如压缩),因此它显示为二进制数据。

您可以解压缩它以将数据解析为纯可读文本。或者当你调用远程http服务器时,你可以告诉http服务器你支持gzip,远程服务器应该尊重并发回纯文本数据。

于 2012-09-20T06:55:08.667 回答