4 Replies Latest reply on May 13, 2011 9:43 AM by Steam s

    extracting http header from esb message?

    Steam s Newbie

      Hi All,

               Could someone please explain how to extract an http header from an esb message?

       

      Say in the input esb message, I have an http parameter "session id" coming as part of the http response.

       

      I want to extract this session id, and want to put it in the esb message property or xslt param, so that i can use it later in some other request.

       

      E.g. sending a corresponding http request and settting in the http header the value of "session id" that i extracted from the last response. 

       

      thanks.

        • 1. extracting http header from esb message?
          Tom Fennelly Master

          Are you using the <http:gateway> ?  If so, see the HttpGateway docs re getting request info.  There you'll see how to get the HttpRequest instance from the ESB message and then from the HttpRequest you can get the list of HttpHeaders.

          • 2. extracting http header from esb message?
            Steam s Newbie

            Thanks Tom for the info. For a bit inside to my problem, you can have a look here in another thread: http://community.jboss.org/thread/166625?tstart=0

             

            I am using HttpRouter action and haven't used http gateway before. I am now going to look into the docs you have given reference too. May be if you could provide me with some small code snippet example that would be great.

             

            Thanks again! much appreciated.

            • 3. extracting http header from esb message?
              Steam s Newbie

              hi tom,

                        this is how i am trying to do as per your suggestion:

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

              ...

              ...

              <service>

              ...

                   <action name="NextServiceRouter" class="org.jboss.soa.esb.actions.StaticRouter">

                                                                     <property name="destinations">

                                                                                    <route-to service-category="YpsilonService" service-name="Router"/>

                                                                     </property>

                     </action>

               

              ...

               

              </service>

                      

               

              <service category="YpsilonService" name="Router" description="" invmScope="GLOBAL">

                          <listeners>

                              <http-gateway name="Http"/>

                          </listeners>

                          <actions mep="RequestResponse">

                              <!-- Service Aactions.... -->

               

                                                                     <action name="httpClient" class="com.traveltainment.integra.middleware.ypsilon.httpClient.httpClientRouter"/>

                             

                          </actions>

              </service>

               

               

              And the httpClientRouter class

               

              public class httpClientRouter implements ActionLifecycle

              {

              ...

              ..

              ..

              public Message process(final Message message)

                {

               

               

                  try

                  {

                      System.out.println("****************************************");

                    HttpRequest requestInfo = HttpRequest.getRequest(message);

               

                  }

               

              ..

              }}

               

              But in my class above, I could not able to make an instance of class HttpRequest to proceed further?

               

              I am getting compilation error. The HttpRequest is not found.

               

              Do I need to add some common library in my POM?

               

              Pls help.

              • 4. extracting http header from esb message?
                Steam s Newbie

                Hi tom,

                          A bit of more success, earlier i was using jbossesb 4.4 and hence couldnt find HttpRequest class, but now i have upgraded to 4.8.

                 

                Now in my httpRequest object, i need to set the following headers:

                 

                POST / HTTP/1.1\r

                accept: application/xml\r

                accept-encoding: gzip\r

                transfer-encoding: identity\r

                api-version: 3.2\r

                accessmode: conso\r

                accessid: conso_id agent_id\r

                authmode: pwd\r

                session: \r

                authorization: Basic dGVzdHVzZXI6bXlzZWNyZXQ=\r

                connection: close\r

                content-Length: \r\n\r\n

                 

                Could you help me set that ?