以下代码使用的是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>
Web端集成XML:
<!-- 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>
客户端向服务器发出请求,服务器端获取代码 并处理Request对象,但服务器在发送时抛出以下内容 回复邮件:
SEVERE:Servlet [Multipart]的Servlet.service()在路径[/ service-webapp]的上下文中引发异常[请求处理失败;嵌套异常是org.springframework.integration.MessagingException:无法转换回复:没有为类型[com.myobject.MReply]找到合适的HttpMessageConverter并接受类型[[text / html,image / gif,image / jpeg, / ; q = .2, / ; q = .2]]]有根本原因 org.springframework.integration.MessagingException:无法转换回复:没有为[com.myobject.MReply]类型找到合适的HttpMessageConverter并接受类型[[text / html,image / gif,image / jpeg, / ; q = .2, / ; q = .2]
欢迎任何帮助!
答案 0 :(得分:0)
假设com.myobject.MReply
为Serializable
,请尝试在出站网关上设置expected-response-type="com.myobject.MReply"
。它应该使accept标头设置为application/x-java-serialized-object
。
编辑:
或者,如果您不想将其与特定类型绑定,请设置expected-response-type="java.io.Serializable"
。