Announcement Announcement Module
Collapse
No announcement yet.
HTTP POST body - simple transformer? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • HTTP POST body - simple transformer?

    hi,

    I'm trying to transform an x-www-form-urlencoded POST body to a JMS message. The POST parameters contain both the destination name and the payload. I'm using SI 2.1.0 so that I have dynamic destination expression available on the outbound-channel-adapter.

    Example POST body might look like this. The 'body' param should become the message payload.
    Code:
     queue=TESTQUEUE&body=<foo>hello world</foo>
    I'm hoping I can somehow do this with SpEL rather than writing transformer classes..

    Code:
        <int-http:inbound-channel-adapter 
            id="httpIn" 
            channel="httpRcvdChannel"
            name="/tojms"
            supported-methods="POST"
            />
        <int:channel id="httpRcvdChannel"/>
        
        <!-- what goes in the expression attribute?? -->
        <int:transformer
            input-channel="httpRcvdChannel"
            output-channel="jmsOutChannel"
            expression="payload"  
            />
        
        <int-jms:outbound-channel-adapter 
            id="jmsOut"
            destination-expression="header.queue"
            channel="jmsOutChannel"
            />
        <int:channel id="jmsOutChannel"/>
    What's the simplest way to do the transformation?

  • #2
    Hello.

    Try this:
    HTML Code:
    <chain  input-channel="httpRcvdChannel"  output-channel="jmsOutChannel">
    	<transformer expression="payload.toSingleValueMap()"/>
    	<header-enricher>
    		<header name="queue" value="payload.queue"/>
    	</header-enricher>
    	<transformer expression="payload.body"/>
    </chain>
    Cheers,
    Artem Bilan

    Comment


    • #3
      great stuff, thanks Artem.

      Comment

      Working...
      X