<directinvoke> and multiple POST parameters

fredpyo
User offline. Last seen 9 weeks 6 days ago. Offline
Joined: 01/08/2010
Points: 31

 Hi, I'm trying to use <directinvoke> to send information (using POST) to a server page that accepts the same parameter several times. Let me explain this in HTML form.

 

<form action="http://200.9.4.6/test.php" method="post">
   <input name="test[]" value="uno" />
   <input name="test[]" value="dos" />
   <input name="test[]" value="tres" />
   <input type="submit">
</form>

I would like to use directinvoke to call this page, but have not found a way to send the test[] post variable several times.

To begin with, I can only use a parameter once in the <directinvoke> tag, that is invalid. So I guess it should have something to do with the request body attribute, but I have not been successful in sending data correctly using this attribute.

Any help would be greatly appreciated.

Cheers,

Federico

 

0
Your rating: None
nzblue_fish
nzblue_fish's picture
User offline. Last seen 2 weeks 4 days ago. Offline
Joined: 09/30/2009
Points: 1165

Hi Federico,

I can't actually test the directinvoke at the moment, but you might try something like this. There's a reference in the documentation on doing something like this if you search for directinvoke (see the Dynamic Endpoints or Parameters for <directinvoke> ) section.

<operation name="run_Test20">

        <variables>
            <variable name="POSTParms" type="string" default="" />
            <variable name="testItems" type="document">
                <root>
                    <test>uno</test>
                    <test>dos</test>
                    <test>tres</test>
                    <test>something extra</test>
                </root>
            </variable>
            <variable name="testItem" type="document" />
            <variable name="POSTendpoint" type="string" default="http://200.9.4.6/test.php?" />
        </variables>

        <foreach items="$testItems/*:root/*:test" variable="testItem">
            <if condition="$POSTParms eq ''">
                <assign fromexpr="concat('test=',encode-for-uri($testItem/text()))"
                    outputvariable="POSTParms" />
                <else>
                    <assign
                        fromexpr="concat($POSTParms,'&amp;','test=',encode-for-uri($testItem/text()))"
                        outputvariable="POSTParms" />
                </else>
            </if>
        </foreach>

        <display message="POSTParms" variable="POSTParms" />
        <assign fromexpr="concat($POSTendpoint,$POSTParms)" outputvariable="POSTendpoint" />
        <display message="POSTendpoint =:" variable="POSTendpoint" />
       
<!--        <directinvoke endpoint="$POSTendpoint" method="POST" outputvariable="POSTResponse" />-->
       
    </operation>

</mashup> 
 
I've commented out the <directinvoke> since I don't have an endpoint to test it on, but here's the display output that I get from running this emml:
Executing the script...
POSTParms    test=uno&test=dos&test=tres&test=something%20extra
POSTendpoint =: http://200.9.4.6/test.php?test=uno&test=dos&test=tres&test=something%20extra
 
Hope this helps.
 
Cheers, Innes