7 Replies Latest reply on Oct 12, 2011 6:18 PM by arnoldjohansson

    HttpGateway Question...

    david.escandell

      I have used the HttpGateway to get a request into the system.  This has worked fine.  Now I am wanting to return a response to the caller (calling browser, maybe)  How do I go about doing this? I have found several comments in the quickstarts and the documentation, however I think I have just been dancing around the magical incantation.  Any ideas?

       

      Thanks.

        • 1. Re: HttpGateway Question...
          mageshbk

          Have you declared your action to be a RequestResponse mep? Have a look at the http_gateway quickstart.

          • 2. Re: HttpGateway Question...
            david.escandell

            yes - I followed the quickstart.  Can you please tell me the right way to get content to go out of the gateway to the browser?

            Here are the relevant files as I have implemented them...

             

            jboss-esb.xml:

            <?xml version="1.0"?>

            <jbossesb parameterReloadSecs="5"

            xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.2.0.xsd"

            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.2.0.xsd http://anonsvn.jboss.org/repos/labs/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.2.0.xsd">

            <providers>

              <!-- These queues are the local message aware queues defined for the ESB  -->

              <jms-provider connection-factory="ConnectionFactory" name="JBossMessaging">

               <property name="max-sessions-per-connection" value="5"/>

               <property name="max-xa-sessions-per-connection" value="5"/>

               <!-- Start of LOS/Extranet ESB Queues -->

               <jms-bus busid="incomingChannel">

                <jms-message-filter dest-name="queue/incoming" dest-type="QUEUE" transacted="true"/>

               </jms-bus>

               <jms-bus busid="incomingGWChannel">

                <jms-message-filter dest-name="queue/incomingGW" dest-type="QUEUE" transacted="true"/>

               </jms-bus>

              </jms-provider>

              <http-provider name="ImageUploadRequestHTTP">

               <http-bus busid="imageUploadHTTPRequest"/>

              </http-provider>

              <!--  added for testing jboss esb solution -->

            </providers>

            <services>

              <service category="Test" description="dooty" invmScope="GLOBAL" name="HttpGatewayTestService">

               <listeners>

                <http-gateway busidref="imageUploadHTTPRequest"

                 name="HttpGatewayListener" payloadAs="BYTES" urlPattern="services/upload/*">

                 <asyncResponse statusCode="200"/>

                </http-gateway>

                <jms-listener busidref="incomingChannel" maxThreads="5" name="incomingListener"/>

                <jms-listener busidref="incomingGWChannel" is-gateway="true"

                 maxThreads="5" name="incomingGatewayListener"/>

               </listeners>

               <actions mep="RequestResponse" requestLocation="request" responseLocation="response">

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

                 <property name="message" value="Got It"/>

                </action>

                <action class="com.famc.esb.actions.RequestHandlerAction"

                 name="RequestHandler" process="process"/>

               </actions>

              </service>

            </services>

            </jbossesb>

             

            RequestHandlerAction.java:

            package com.famc.esb.actions;

             

             

            import org.jboss.soa.esb.actions.AbstractActionPipelineProcessor;

            import org.jboss.soa.esb.actions.ActionProcessingException;

            import org.jboss.soa.esb.helpers.ConfigTree;

            import org.jboss.soa.esb.message.Message;

             

             

            public class RequestHandlerAction  extends

            AbstractActionPipelineProcessor {

             

             

                      public RequestHandlerAction(ConfigTree config){

                                System.out.println("Initializing RequestHandlerAction");

                      }

             

                      @Override

                      public Message process(Message message) throws ActionProcessingException {

                                System.out.println("inside RequestHandlerAction.process(Message message)");

             

             

             

                                return message;

                      }

             

             

            }

            • 3. Re: HttpGateway Question...
              david.escandell

              Maybe the HttpGateway is the wrong way to implement a REST based webservice type of thing.  Even thoung I am not usign SOAP, would the WebServiceProducer be a better way to go?

              • 4. Re: HttpGateway Question...
                arnoldjohansson

                In your AP, you just need to put the "stuff" (e g html-content) that you want your browser to display, in the body of the message object.

                 

                Like so:

                 

                String response = "some response in e g html";

                message.getBody().add(response);

                return message;

                • 5. Re: HttpGateway Question...
                  mageshbk

                  Since you want to send a response back remove this property

                  <asyncResponse statusCode="200"/>
                  
                  • 6. Re: HttpGateway Question...
                    kotaris

                    Did this work for you? I am also trying to implement the same way with both jms provider and http provider and need to pass an object in the http request and get an object back from the response.

                     

                    Can the same action handle both for jms message and http message? If so can you share the code of how you implemented?

                    • 7. Re: HttpGateway Question...
                      arnoldjohansson

                      If the input (your object - which will become the payload of an ESB Aware Message) to the action is the same regardless of provider, then the action can handle it directly. The config in the jboss-esb.xml from David looks about right. There should be one jms listener, and one http listener in the same service. Both will then pass an ESB Aware Message on to the first action in the service.