Results 1 to 3 of 3

Thread: HTTP POST body - simple transformer?

Hybrid View

  1. #1
    Join Date
    Aug 2004
    Location
    London, UK
    Posts
    339

    Default 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?
    Darren Davison.
    Public Key: 0xE855B3EA

  2. #2
    Join Date
    Jan 2009
    Location
    Ukraine, Kharkov
    Posts
    632

    Default

    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

  3. #3
    Join Date
    Aug 2004
    Location
    London, UK
    Posts
    339

    Default

    great stuff, thanks Artem.
    Darren Davison.
    Public Key: 0xE855B3EA

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •