Announcement Announcement Module
Collapse
No announcement yet.
xpath-splitter does not seem to work with marshalling-transformer Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • xpath-splitter does not seem to work with marshalling-transformer

    Hi,

    Following confiuration throws below error after sending an object to in channel:

    Code:
    <si:channel id="in"/>
    <si:channel id="out"/>
    <si:channel id="marshal"/>
    <stream:stdout-channel-adapter id="stdout" channel="out" append-newline="true" />
    
    <si-xml:marshalling-transformer marshaller="castorMarshaller" input-channel="in" output-channel="marshal" result-type="StringResult"/>
    <si-xml:xpath-splitter input-channel="marshal" output-channel="out">
      <si-xml:xpath-expression expression="/employee/location"/>
    </si-xml:xpath-splitter>
    Code:
    Exception in thread "main" org.springframework.integration.core.MessagingException: failed to split Message payload
    	at org.springframework.integration.xml.splitter.XPathMessageSplitter.splitMessage(XPathMessageSplitter.java:120)
    	at org.springframework.integration.splitter.AbstractMessageSplitter.handleRequestMessage(AbstractMessageSplitter.java:36)
    	at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:91)
    	at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:59)
    	at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:103)
    	at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:90)
    	at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:43)
    	at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:116)
    	at org.springframework.integration.channel.MessageChannelTemplate.doSend(MessageChannelTemplate.java:223)
    	at org.springframework.integration.channel.MessageChannelTemplate.send(MessageChannelTemplate.java:181)
    	at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.sendReplyMessage(AbstractReplyProducingMessageHandler.java:119)
    	at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:107)
    	at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:59)
    	at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:103)
    	at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:90)
    	at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:43)
    	at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:116)
    	at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:94)
    	at si.SI.main(SI.java:32)
    Caused by: java.lang.IllegalArgumentException: Unsupported payload type [org.springframework.xml.transform.StringResult]. The XPathMessageSplitter only accepts [org.w3c.dom.Node] or [java.lang.String] typed payloads.
    	at org.springframework.integration.xml.splitter.XPathMessageSplitter.splitMessage(XPathMessageSplitter.java:109)
    	... 18 more
    Even though marshal chanel contains String message, error says: The XPathMessageSplitter only accepts [org.w3c.dom.Node] or [java.lang.String] typed payloads.

    The splitter works correctly if a xml string is passed directly to in channel. e.g.
    Code:
    "<?xml version=\"1.0\" encoding=\"UTF-8\"?><employee><name>K.D.</name><location><city>?</city></location></employee>"
    Marshaller also works correctly and produces valid XML.
    Last edited by krd; Oct 21st, 2010, 07:21 AM.

  • #2
    While finding a workaround, I noticed that marshalling-transformer outputs payload type StringResult; whereas xpath-splitter expects String. This unnecessarily requires one service activator in the middle to convert StringResult to String.

    Any ways to eliminate this unwanted service activator?

    Comment


    • #3
      You can use transformer instead with a simple SpEL expression
      Code:
      <transformer input-channel="inChannel" output-channel="outChannel" expression="payload.toString()"/>

      Comment


      • #4
        Thanks. Looks like "expression" construct is not supported by Spring Integration 1.x and Spring 2.5 combination.

        But <object-to-string-transformer> works.

        Comment

        Working...
        X