3 Replies Latest reply on May 23, 2011 5:33 AM by tfennelly

    Apache Commons HttpRouter Uses

    davidmpaz

      Hello,

       

      Can any one tell me how it is possible to route a message in the pipeline to an external php application. Actually I'm hitting the proper php script and firing its execution in another server, but for some reason I'm not able to handle any request parameter in there. I already checked that the message contain the proper content and the url is getting hit also as I said, I just dont know how can I handle the request in the php application.

       

      For example if I have a variable in the message body named "result" which has an string value how can I use that in the php application?

       

      Note: I have tried to handle the POST, GET and REQUEST php variables respectively without success.

       

      Any help or idea will be greatly appreciated, I would like to take advantage of this if possible and not code myself the request.

       

      thanks in advance.

       

      David

        • 1. Re: Apache Commons HttpRouter Uses
          dward

          Try adding these properties to your HttpRouter action:

           

          <property name="method" value="POST"/>

          <property name="unwrap" value="true"/>

          <property name="get-payload-location" value="result"/>

           

          Let us know how it goes.

          • 2. Re: Apache Commons HttpRouter Uses
            davidmpaz

            Hi david,

             

            No sucess with your suggestions, I've tried several combination possibles and nothing , I have even try to add data to the default entry of the message and not a custom location and no result neither. This is my current scenario in more detail. As I said I tried to set up all variants of your suggestion but since I wasn't able to get some result I revert back to default set up that my eclipse plugin configure it for me.

             

            Actions chain:

             

            <actions>

                <action

                 class="org.jboss.soa.esb.actions.scripting.GroovyActionProcessor" name="add default entry">

                 <property name="script" value="/groovy/set-message-default-entry.groovy"/>

                </action>

                <action class="org.jboss.soa.esb.actions.SystemPrintln" name="print">

                 <property name="message" value="The message"/>

                </action>

                <action class="org.jboss.soa.esb.actions.routing.http.HttpRouter" name="notify">

                 <property name="method" value="GET"/>

                 <property name="endpointUrl" value="http://www.root.local/test/printrequest.php"/>

                </action>

            </actions>

             

            in the groovy action script I set up the default entry value for the message, this is it:

             

            import org.jboss.soa.esb.message.*

             

            // set the default entry

            message.getBody().add("this is a testing message");

             

            In the print action I can check that is it correctly added to the default entry, if I make the println action print full message the entire message is show as I originally need it.

             

            Finally, that php file, and the only thing it does is to grab the $_REQUEST variable and print it in a file, each time I invoke the actions the file get updated but nothing is in it, If I test in explorer it prints everything fine, it is a simple file, here is it:

             

            <?php

                $content = "";

                foreach($_REQUEST as $name => $value){

                    $content .= $name . " => " . $value . "\n";

                }

                file_put_contents(dirname(__FILE__) . "/request.txt", $content);

            ?>

             

            I'm using, JbossESB 4.8 with Jboss-5.1.0.GA, my eclipse plugin version for the ESB: 1.3.0.v201004301510N-H181-GA.

             

            Currently I just dont know what am I missing, so please I will appreciate a lot if this could be clarified little for me, I have coded already a custom action to make the request but that is not the way I would like to do the things in a long term development. Please if some more information is needed ask for it.

             

            Thanks for the answer and for your time.

             

            greetings, david

            • 3. Apache Commons HttpRouter Uses
              tfennelly

              Not sure if you're asking an ESB related question, or a question about PHP.  If it's the later then this is not the correct forum for that.

               

              As for the config you posted... you specified the use of the GET method, in which case the ESB message payload is not relevant.  You need to use the POST method if you want to post a payload.

               

              Note you can always define your own custom method names and then implement your own HttpMethodFactory e.g. the "PAZ" method via the "org.jboss.soa.esb.actions.routing.http.PAZHttpMethodFactory".

               

              Another thing to do is to proxy the request through a HTTP sniffer and so have a look at the raw HTTP request going to your external app.  If it has all the requitred info in it then you can just forget about the ESB and concentrate on your external php app.