Spring integration 入站网关无法发送回复

Spring integration 入站网关无法发送回复,spring-integration,Spring Integration,下面的代码使用的是Spring Integration 3.0.1 客户端集成XML: <int:channel id="serviceTWeb"></int:channel> <int:gateway id="serviceTGW" default-request-channel="serviceTWeb" service-interface="com.test.ServiceTWeb"> </int:g

下面的代码使用的是Spring Integration 3.0.1

客户端集成XML:

    <int:channel id="serviceTWeb"></int:channel>
    <int:gateway id="serviceTGW" default-request-channel="serviceTWeb"
            service-interface="com.test.ServiceTWeb">
    </int:gateway>
    <int-http:outbound-gateway
            url="http://testserver:8080/service-webapp/service"
            http-method="POST" id="RequestTNHTTP" reply-timeout="2000"
            request-channel="serviceTWeb" message-converters="conv>
    </int-http:outbound-gateway>

    <bean id="conv" class="org.springframework.integration.http.converter.SerializingHttpMessageConverter">
    </bean>
    <!-- The following uses a ServiceActivator on service -->
    <bean id="stweb" class="test.poc.si.ServiceTWeb"></bean>

    <bean id="conv" class="org.springframework.integration.http.converter.SerializingHttpMessageConverter">
    </bean>

    <int:channel id="requestChannel"></int:channel>
    <int:channel id="replyChannel"></int:channel>

    <int:service-activator input-channel="requestChannel" ref="stweb"
            method="service" requires-reply="true" id="webserv"
            output-channel="replyChannel">
    </int:service-activator>
    <int-http:inbound-gateway request-channel="requestChannel"
            supported-methods="POST" path="/service" message-converters="conv"
            reply-channel="replyChannel">
            </int-http:inbound-gateway>


假设
com.myobject.MReply
是可序列化的
,尝试在出站网关上设置
expected response type=“com.myobject.MReply”
。它应该使accept头设置为
application/x-java-serialized-object

编辑:


或者,设置
expected response type=“java.io.Serializable”
如果您不想将其绑定到特定的类型。

是否有其他方法可以做到这一点,我宁愿不指定预期的类型。第一个选项的作用是expected response type=“com.myobject.MReply”,但当我在网关中尝试接受头时,我得到了以下结果:第一个成功了,但是当我尝试接受头时,我得到了:DEBUG org.springframework.beans.BeanUtils-无属性编辑器[com.my.ReplyEditor]根据“编辑器”后缀约定org.springframework.beans.ConversionNotSupportedException找到com.my.Reply类型:未能将“org.springframework.http.ResponseEntity”类型的值转换为所需类型“com.my.Reply”;嵌套异常为java.lang.IllegalStateException:无法将[org.springframework.http.ResponseEntity]类型的值转换为所需类型[com.my.Reply]:找不到匹配的编辑器或转换策略修复程序?我不完全确定为什么这样做不起作用(但将对此进行研究);它意味着
实体.hasBody()
返回false(即使响应显然有一个主体)。然而,
expected response type=“java.io.Serializable”
对我来说可以正常工作(并且您不需要accept头),因为一个
Serializable
的预期响应类型将设置它。事实证明,这是底层
restemplate
的工作方式-如果您不给它一个
预期响应类型
,您得到的是一个
响应属性
,只有标题和状态代码,没有正文。对不起,我误导了你。因此需要与响应内容类型兼容的
预期响应类型
;我们会修好这些文件。