2 Replies Latest reply on Jan 19, 2005 4:44 PM by 424530

    Changing the HTTP status code for HTTP Adapter receiving messages.

    424530
      Hi,

      We are using the HTTP adapter in InterConnect 9.0.4 to receive messages. We would like to change the HTTP status returned to an external partner posting messages to the adaper from 200 OK to 202 ACCEPTED. We have made a ReceiverCustomizer class (which is \called when receiving a message) with both customizeTransportMessage and createReplyMessage methods, but can't seem to find a way to change the HTTP status there. Is there a way to do this?

      - Arild Strømhylden
        • 1. Re: Changing the HTTP status code for HTTP Adapter receiving messages.
          Lakrishn-Oracle
          Hi Arild,

          Currently oracle/oai/agent/adapter/transport/basic/TransportServlet.java (method sendMessage()) does not provide any means for setting one of the 20x success codes, in fact the servlet doesn't even set SC_OK. Potentially the web.xml configuration could be extended to allow the user to set the success code , e.g.

          <web-app>
          <servlet>
          <servlet-name>
          transportServlet
          </servlet-name>
          <servlet-class>
          oracle.oai.agent.adapter.transport.basic.TransportServlet
          </servlet-class>
          ...
          <init-param>
          <param-name>httpResponseSuccess</param-name>
          <param-value>202</param-value> // or SC_ACCEPTED
          </init-param>

          This would have to be coded, i.e. an enhancement request.
          I have passed on your feedback to Development, for reviewing the request. Thanks for your inputs.

          - Latha
          • 2. Re: Changing the HTTP status code for HTTP Adapter receiving messages.
            424530
            Thank you,

            Actually, it was not that hard to do. The fact that it doesn't set SC_OK makes the following work: Just create a Servlet class which inherits from transportservlet, set the response code and call the super.doPost() method. Then just deploy the web-app containing the new transportservlet and modify the web.xml to use this servlet instead of the default TransportServlet. The init parameters in web.xml for transportServlet will also have to be set for the new servlet.

            import java.io.IOException;
            import javax.servlet.ServletException;
            import javax.servlet.http.HttpServletRequest;
            import javax.servlet.http.HttpServletResponse;
            import oracle.oai.agent.adapter.transport.basic.TransportServlet;

            /**
            * @author Harald Stensholt
            */
            public class AcceptingTransportServlet extends TransportServlet {

                 public void doPost(HttpServletRequest request, HttpServletResponse response)
                           throws ServletException, IOException {

                      // Setting 202/Accepted in the response
                      response.setStatus(HttpServletResponse.SC_ACCEPTED);
                      super.doPost(request, response);
                 }
            }

            Please don't "fix" this feature ;)