Help get this topic noticed by sharing it on Twitter, Facebook, or email.

HTTP Post parameter

*Message imported, originaly posted: Wed, 08 Feb 2012 14:29:15 .
Hi

I have an http inbound enpoint like this:

<http:inbound-endpoint host="localhost" path="prova" port="8888" contentType="text/xml" method="POST">
<http:body-to-parameter-map-transformer />
</http:inbound-endpoint>
<transformer ref="ParameterMapToXmlString"/>

The endpoint receives some parameter with post method. AS you can see i use <http:body-to-parameter-map-transformer /> to have a map object to access my parameters. But when in my custom transformer ParameterMapToXmlString I try to access my parameters like this:

message.getInboundProperty("parameterName") i get a null value.

But if I use GET as method to pass the parameter the value is the right value i inserted in a html form.

Am i missing something in order to make the Post work??

Thanks
Regards
Alberto
1 person has
this question
+1
Reply
  • *Message imported, originaly posted: Fri, 05 Nov 2010 07:21:05 .
    Try enabling debug or simply print out the MuleMessage to see what's going
    on and what scopes properties are in. I have a feeling the lookup is wrong,
    you should fetch values from the payload, which is a map now.

    Check out the loanbroker-simple example bundled with Mule, it does something
    very similar.

    HTH,
    Andrew
    Hi
    I have an http inbound enpoint like this:


    <http:inbound-endpoint host="localhost" path="prova" port="8888"

    contentType="text/xml" method="POST">
    <http:body-to-parameter-map-transformer />
    </http:inbound-endpoint>
    <transformer ref="ParameterMapToXmlString"/>
    The endpoint receives some parameter with post method. AS you can see i

    use <http:body-to-parameter-map-transformer /> to have a map object to
    access my parameters. But when in my custom transformer
    ParameterMapToXmlString I try to access my parameters like this:

    message.getInboundProperty("parameterName") i get a null value.
    But if I use GET as method to pass the parameter the value is the right

    value i inserted in a html form.

    Am i missing something in order to make the Post work??
    Thanks
    Regards
    Alberto









  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned kidding, amused, unsure, silly happy, confident, thankful, excited sad, anxious, confused, frustrated

  • *Message imported, originaly posted: Fri, 05 Nov 2010 09:01:47 .
    Hi Andrew

    thanks for replying.

    Following your suggestion i printed out the mule message.

    In case of post this was the output:
    org.mule.DefaultMuleMessage
    {
    id=83a22990-8b3f-4622-a724-707daca64799
    payload=java.util.HashMap
    correlationId=<not set>
    correlationGroup=-1
    correlationSeq=-1
    encoding=UTF-8
    exceptionPayload=<not set>

    Message properties:
    INVOCATION scoped properties:
    Content-Type=text/xml
    http.method=POST
    INBOUND scoped properties:
    Accept=text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
    Accept-Charset=ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Accept-Encoding=gzip,deflate
    Accept-Language=it-it,it;q=0.8,en-us;q=0.5,en;q=0.3
    Connection=true
    Content-Length=18
    Content-Type=application/x-www-form-urlencoded
    Host=localhost:8888
    Keep-Alive=true
    MULE_ORIGINATING_ENDPOINT=endpoint.http.localhost.8888.prova
    MULE_REMOTE_CLIENT_ADDRESS=/0:0:0:0:0:0:0:1:50946
    User-Agent=Mozilla/5.0 (Windows; U; Windows NT 6.0; it; rv:1.9.1.15) Gecko/20101026 Firefox/3.5.15
    http.context.path=/prova
    http.method=POST
    http.request=/prova
    http.request.path=/prova
    http.version=HTTP/1.1
    OUTBOUND scoped properties:
    MULE_ENCODING=UTF-8
    SESSION scoped properties:
    }

    As you said my parameter is not in the inbouns scope of the message.

    In case of GET the message is:

    org.mule.DefaultMuleMessage
    {
    id=ea72587b-b9d2-4b18-b49b-422c389f3be7
    payload=java.util.HashMap
    correlationId=<not set>
    correlationGroup=-1
    correlationSeq=-1
    encoding=UTF-8
    exceptionPayload=<not set>

    Message properties:
    INVOCATION scoped properties:
    Content-Type=text/xml
    http.method=GET
    INBOUND scoped properties:
    Accept=text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
    Accept-Charset=ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Accept-Encoding=gzip,deflate
    Accept-Language=it-it,it;q=0.8,en-us;q=0.5,en;q=0.3
    Connection=true
    Host=localhost:8888
    Keep-Alive=true
    MULE_ORIGINATING_ENDPOINT=endpoint.http.localhost.8888.prova
    MULE_REMOTE_CLIENT_ADDRESS=/0:0:0:0:0:0:0:1:50954
    User-Agent=Mozilla/5.0 (Windows; U; Windows NT 6.0; it; rv:1.9.1.15) Gecko/20101026 Firefox/3.5.15
    http.context.path=/prova
    http.method=GET
    http.request=/prova?xmlSalesOrder=ciao
    http.request.path=/prova
    http.version=HTTP/1.1
    parameter=hello
    OUTBOUND scoped properties:
    MULE_ENCODING=UTF-8
    SESSION scoped properties:
    }

    In the case the parameter is accessible in the inbound properties! (you can see it highlighted).

    However, as you said, even in the case of POST is very easy to retreive the parameters as the payload is a MAP object.

    Alberto
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned kidding, amused, unsure, silly happy, confident, thankful, excited sad, anxious, confused, frustrated

  • *Message imported, originaly posted: Fri, 05 Nov 2010 10:37:07 .
    This is pretty consistent, as for POST everything is in the body, not url.
    Mule maps url after the service part to a param for convenience.

    HTH,
    Andrew
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned kidding, amused, unsure, silly happy, confident, thankful, excited sad, anxious, confused, frustrated