<int-http:inbound-gateway id="omega"
request-channel="requestChannel" error-channel="errorChannel"
path="/api/mapList" reply-channel="channel9"
supported-methods="POST">
<int-http:request-mapping consumes="application/xml"/>
</int-http:inbound-gateway>
...
<si-xml:xpath-splitter input-channel="requestChannel"
output-channel="splitterChannel" id="xpathSplitter">
<si-xml:xpath-expression id="xpathExpression"
expression="//mapRequests/mapRequest" />
</si-xml:xpath-splitter>
如果我将请求映射更改为text / html或text / plain并将客户端内容类型更改为匹配 - 它可以正常工作。
但是当客户端具有标题Content-Type:application / xml时,它会产生以下异常
org.springframework.messaging.MessagingException: failed to split Message payloa
d
at org.springframework.integration.xml.splitter.XPathMessageSplitter.spl
itMessage(XPathMessageSplitter.java:119)
at org.springframework.integration.splitter.AbstractMessageSplitter.hand
leRequestMessage(AbstractMessageSplitter.java:54)
at org.springframework.integration.handler.AbstractReplyProducingMessage
Handler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:170)
at org.springframework.integration.handler.AbstractMessageHandler.handle
Message(AbstractMessageHandler.java:78)
at org.springframework.integration.dispatcher.AbstractDispatcher.tryOpti
mizedDispatch(AbstractDispatcher.java:116)
at org.springframework.integration.dispatcher.UnicastingDispatcher.doDis
patch(UnicastingDispatcher.java:101)
at org.springframework.integration.dispatcher.UnicastingDispatcher.dispa
tch(UnicastingDispatcher.java:97)
at org.springframework.integration.channel.AbstractSubscribableChannel.d
oSend(AbstractSubscribableChannel.java:77)
at org.springframework.integration.channel.AbstractMessageChannel.send(A
bstractMessageChannel.java:255)
at org.springframework.integration.channel.AbstractMessageChannel.send(A
bstractMessageChannel.java:223)
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(Ge
nericMessagingTemplate.java:109)
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(Ge
nericMessagingTemplate.java:44)
at org.springframework.messaging.core.AbstractMessageSendingTemplate.sen
d(AbstractMessageSendingTemplate.java:94)
at org.springframework.integration.handler.AbstractReplyProducingMessage
Handler.sendMessage(AbstractReplyProducingMessageHandler.java:260)
at org.springframework.integration.handler.AbstractReplyProducingMessage
Handler.sendReplyMessage(AbstractReplyProducingMessageHandler.java:241)
at org.springframework.integration.handler.AbstractReplyProducingMessage
Handler.produceReply(AbstractReplyProducingMessageHandler.java:205)
at org.springframework.integration.handler.AbstractReplyProducingMessage
Handler.handleResult(AbstractReplyProducingMessageHandler.java:199)
at org.springframework.integration.handler.AbstractReplyProducingMessage
Handler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:177)
at org.springframework.integration.handler.AbstractMessageHandler.handle
Message(AbstractMessageHandler.java:78)
at org.springframework.integration.dispatcher.AbstractDispatcher.tryOpti
mizedDispatch(AbstractDispatcher.java:116)
at org.springframework.integration.dispatcher.UnicastingDispatcher.doDis
patch(UnicastingDispatcher.java:101)
at org.springframework.integration.dispatcher.UnicastingDispatcher.dispa
tch(UnicastingDispatcher.java:97)
at org.springframework.integration.channel.AbstractSubscribableChannel.d
oSend(AbstractSubscribableChannel.java:77)
at org.springframework.integration.channel.AbstractMessageChannel.send(A
bstractMessageChannel.java:255)
at org.springframework.messaging.core.GenericMessagingTemplate.doSend(Ge
nericMessagingTemplate.java:109)
at org.springframework.messaging.core.GenericMessagingTemplate.doSendAnd
Receive(GenericMessagingTemplate.java:144)
at org.springframework.messaging.core.GenericMessagingTemplate.doSendAnd
Receive(GenericMessagingTemplate.java:44)
at org.springframework.messaging.core.AbstractMessagingTemplate.sendAndR
eceive(AbstractMessagingTemplate.java:75)
at org.springframework.integration.gateway.MessagingGatewaySupport.doSen
dAndReceive(MessagingGatewaySupport.java:250)
at org.springframework.integration.gateway.MessagingGatewaySupport.sendA
ndReceiveMessage(MessagingGatewaySupport.java:224)
at org.springframework.integration.http.inbound.HttpRequestHandlingEndpo
intSupport.actualDoHandleRequest(HttpRequestHandlingEndpointSupport.java:473)
at org.springframework.integration.http.inbound.HttpRequestHandlingEndpo
intSupport.doHandleRequest(HttpRequestHandlingEndpointSupport.java:370)
at org.springframework.integration.http.inbound.HttpRequestHandlingMessa
gingGateway.handleRequest(HttpRequestHandlingMessagingGateway.java:101)
at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(
HttpRequestHandlerAdapter.java:51)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(Dispatch
erServlet.java:938)
at org.springframework.web.servlet.DispatcherServlet.doService(Dispatche
rServlet.java:870)
at org.springframework.web.servlet.FrameworkServlet.processRequest(Frame
workServlet.java:961)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServ
let.java:863)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:755)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkSer
vlet.java:837)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684
)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java
:501)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.j
ava:137)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.jav
a:557)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandl
er.java:231)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandl
er.java:1086)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:
428)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandle
r.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandle
r.java:1020)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.j
ava:135)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(Cont
extHandlerCollection.java:255)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerColl
ection.java:154)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper
.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:370)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(Abstrac
tHttpConnection.java:494)
at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpC
onnection.java:982)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.conten
t(AbstractHttpConnection.java:1043)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:865)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnecti
on.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEn
dPoint.java:667)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEnd
Point.java:52)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPoo
l.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool
.java:543)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.springframework.messaging.MessagingException: unsupported payload
type [[B]
at org.springframework.integration.xml.DefaultXmlPayloadConverter.conver
tToDocument(DefaultXmlPayloadConverter.java:91)
at org.springframework.integration.xml.splitter.XPathMessageSplitter.spl
itMessage(XPathMessageSplitter.java:109)
... 65 more
答案 0 :(得分:1)
如果您已在StackTrace部分编辑了帖子,那将会很棒。它不可读。
但最后我看到了:
引起:org.springframework.messaging.MessagingException:不支持的有效负载类型[[B]
那么,<int-http:inbound-gateway>
与consumes="application/xml"
和<<si-xml:xpath-splitter>
之间所需要的就是这个变换器:
<object-to-string-transformer>
但是,我发现我们可以在byte[]
中支持DefaultXmlPayloadConverter
。因此,请随时就此问题提出JIRA问题:https://jira.spring.io/browse/INT