Spring integration 出站网关正在返回垃圾邮件响应

Spring integration 出站网关正在返回垃圾邮件响应,spring-integration,Spring Integration,我们在项目中使用spring集成。我已经配置了和,如下所示: <int:chain input-channel="PQIssueHistory-AWD10SP7_1-Or-higher-Channel" output-channel="PQIssueHistory-AWD-Rest-Channel" > <int:service-activator ref="msgHandler" method="buildRequestBasedDataSource"

我们在项目中使用spring集成。我已经配置了
,如下所示:

<int:chain  input-channel="PQIssueHistory-AWD10SP7_1-Or-higher-Channel"  output-channel="PQIssueHistory-AWD-Rest-Channel" >

        <int:service-activator ref="msgHandler" method="buildRequestBasedDataSource" />
        <int-jdbc:stored-proc-outbound-gateway
                        auto-startup="true"
                        data-source="routingDataSource"
                        stored-procedure-name="ZSPPQHISTORYLOOKUP "
                        skip-undeclared-results="true"
                        ignore-column-meta-data="true"  
                        use-payload-as-parameter-source = "false"
                        expect-single-result="true">

                                <int-jdbc:sql-parameter-definition name="P_CRDATTIM" direction="IN" type="VARCHAR" />
                                <int-jdbc:sql-parameter-definition name="P_RECORDCD" direction="IN" type="VARCHAR" />
                                 <int-jdbc:sql-parameter-definition name="P_CRNODE" direction="IN" type="VARCHAR" />

                                <int-jdbc:parameter name="P_CRDATTIM" expression="#xpath(payload, '//DST/AWD/storedProcedure/parameter[1]/value')" />
                                <int-jdbc:parameter name="P_RECORDCD"  expression="#xpath(payload,'//DST/AWD/storedProcedure/parameter[2]/value')" />
                                 <int-jdbc:parameter name="P_CRNODE"  expression="#xpath(payload,'//DST/AWD/storedProcedure/parameter[3]/value')" />

        <int-jdbc:returning-resultset name="rowMapper" row-mapper="com.dsths.cs.awd.utils.ResultSetRowMapper"/>

        </int-jdbc:stored-proc-outbound-gateway>
        <int:service-activator ref="msgHandler" method="buildMessageFromExtSysResponse" />

        <int:header-enricher default-overwrite="true"  should-skip-nulls="true"  >
            <int:header name="${headerNames.originalPayload}" expression="payload" />   
        </int:header-enricher>  

    </int:chain>    

 <int:channel id="PQIssueHistory-AWD-Rest-Channel" />
    <int:chain input-channel="PQIssueHistory-AWD-Rest-Channel"  >

        <int-xml:xslt-transformer xsl-resource="${stylesheet.PQIssueComments-REST}"  />
        <int:service-activator  ref="httpOutboundGatewayHandler" method="buildHttpOutboundGatewayRequest" />

        <int-http:outbound-gateway  url-expression="headers.restResourceUrl"
                                    http-method-expression="headers.httpMethod"
                                    expected-response-type="java.lang.String" >
        </int-http:outbound-gateway>
        <int:service-activator ref="msgHandler" method="enrichPayloadXml" />
        <int-xml:xslt-transformer xsl-resource="${stylesheet.PQIssueHistory-Format-Stage-One}" />
        <int-xml:xslt-transformer xsl-resource="${stylesheet.PQIssueHistory-Format-Stage-Two}" />

    </int:chain>

目标是首先命中存储过程,然后命中rest服务。我能够点击存储过程并得到响应。但是,我在使用rest服务时遇到了一些问题。我收到一些奇怪的加密响应。实际上,当我尝试使用rest客户机甚至JUNIT测试用例时,相同的rest服务返回正确的响应。奇怪的是,当我与GUI集成时,rest服务返回一些垃圾数据

以下是日志文件的摘录:

2015-09-01 18:16:52,367 DEBUG http-0.0.0.0-8080-7 [org.springframework.web.client.RestTemplate] Created GET request for "http://10.193.244.251/awdServer/awd/services/v1/instances/2015-08-31-03.17.22.055080T01/history/comments"
2015-09-01 18:16:52,368 DEBUG http-0.0.0.0-8080-7 [org.springframework.web.client.RestTemplate] Setting request Accept header to [text/plain, application/json, application/*+json, */*]
2015-09-01 18:16:53,098 DEBUG http-0.0.0.0-8080-7 [org.springframework.web.client.RestTemplate] GET request for "http://10.193.244.251/awdServer/awd/services/v1/instances/2015-08-31-03.17.22.055080T01/history/comments" resulted in 200 (OK)
2015-09-01 18:16:53,099 DEBUG http-0.0.0.0-8080-7 [org.springframework.web.client.RestTemplate] Reading [java.lang.String] as "application/vnd.dsttechnologies.awd+xml" using [org.springframework.http.converter.StringHttpMessageConverter@2dd2f7a]

.............................................


2015-09-01 18:16:53,101 DEBUG http-0.0.0.0-8080-7 [org.springframework.integration.http.support.DefaultHttpHeaderMapper] setting headerName=[Content-Language], value=[en-US]
2015-09-01 18:16:53,102 DEBUG http-0.0.0.0-8080-7 [org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler] handler 'org.springframework.integration.handler.MessageHandlerChain#407$child#2.handler' sending reply Message: [Payload=?       ?ڸ?
@ Gary Russell's suggestions really worked well in identifying and fixing the issue.

The culprit for junk response is an additional header "accept-encoding: gzip, deflate" being added by IE browser. Spring Integration framework has provided
<header-filter/>
which can be used to get rid of unwanted headers.

<int:header-filter input-channel="unnecessary-headers-removal-channel"
        output-channel="PQIssueHistory-AWD-Rest-Channel" header-names="accept-encoding"/>
2015-09-01 18:16:52367调试http-0.0.0-8080-7[org.springframework.web.client.RestTemplate]已为“”创建获取请求http://10.193.244.251/awdServer/awd/services/v1/instances/2015-08-31-03.17.22.055080T01/history/comments"
2015-09-01 18:16:52368调试http-0.0.0.0-8080-7[org.springframework.web.client.restemplate]将请求接受头设置为[text/plain,application/json,application/*+json,*/*]
2015-09-01 18:16:53098调试http-0.0.0.0-8080-7[org.springframework.web.client.restemplate]获取“的请求”http://10.193.244.251/awdServer/awd/services/v1/instances/2015-08-31-03.17.22.055080T01/history/comments“结果是200(正常)
2015-09-01 18:16:53099使用[org.springframework.http.converter]调试http-0.0.0-8080-7[org.springframework.web.client.restemplate]将[java.lang.String]读取为“application/vnd.dsttechnologies.awd+xml”。StringHttpMessageConverter@2dd2f7a]
.............................................
2015-09-01 18:16:53101调试http-0.0.0.0-8080-7[org.springframework.integration.http.support.DefaultHttpHeaderMapper]设置headerName=[Content Language],value=[en-US]
2015-09-01 18:16:53102调试http-0.0.0-8080-7[org.springframework.integration.http.outbound.HttpRequestExecutingMessageHandler]处理程序'org.springframework.integration.handler.MessageHandlerChain#407$child#2.handler'发送回复消息:[有效负载=??ڸ?
@加里·拉塞尔(Gary Russell)的建议在确定和解决问题方面确实很有效

垃圾响应的罪魁祸首是IE浏览器添加的附加标题“accept encoding:gzip,deflate”。Spring集成框架提供了
,可用于去除不需要的标题


@加里·拉塞尔(Gary Russell)的建议在确定和解决问题方面确实很有效

垃圾响应的罪魁祸首是IE浏览器添加的附加标题“accept encoding:gzip,deflate”。Spring集成框架提供了
,可用于去除不需要的标题



我建议您使用TCP/IP监视器,如wireshark或eclipse附带的监视器来检查这两种情况下的HTTP请求/响应,并比较结果。@GaryRussell感谢您的建议。我已尝试使用wireshark工具来监视请求和响应。响应在“媒体类型”下正确显示“媒体类型:application/vnd.dsttechnologies.awd+xml(3646字节)”,但在“响应短语:OK”下,会显示一个垃圾响应(可能是编码响应)。您能猜出有什么错误吗?如果您需要其他信息,请告诉我。@GaryRussell令人惊讶的是,当我使用Junit测试用例运行时,一切都正常运行。但是,当我从GUI端尝试时,会返回垃圾响应。我真的帮不了您-您需要仔细比较,并查找两者之间的任何差异请求并回复工作/非工作版本。必须存在一些差异,否则它将工作。打开调试日志记录并通过流跟踪消息,查看未删除标头的原因;您可以使用
将其删除。我建议您使用TCP/IP监视器,如wireshark或eclipse附带的监视器来检查t他在这两种情况下都使用HTTP请求/响应,并比较结果。@GaryRussell感谢您的建议。我已尝试使用wireshark工具监视请求和响应。响应正确显示在媒体类型“媒体类型:应用程序/vnd.dsttechnologies.awd+xml(3646字节)”下,但在“响应短语:确定”下,将显示垃圾邮件响应(可能是编码响应)。您能猜出有什么错误吗?如果您需要其他信息,请告诉我。@GaryRussell令人惊讶的是,当我使用Junit测试用例运行时,一切都正常运行。但是,当我从GUI端尝试时,会返回垃圾响应。我真的帮不了您-您需要仔细比较,并查找两者之间的任何差异请求并回复工作/非工作版本。必须存在一些差异,否则它将工作。打开调试日志记录,并在流程中跟踪消息以查看未删除标头的原因;您可以使用
删除它。