axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Walker, Jeff" <Jeff.Wal...@fmr.com>
Subject RE: Modify servers HTTP response from "202 Accepted" to "200 OK"
Date Thu, 16 Aug 2007 15:44:50 GMT
I don't know Axis2, so I can't help you much. I use Axis 1.3.
My basic thought was that you could try to either change the http
header, or create a new response object and set that in the message
context, in the handler. Not sure if this is possible in Axis2.

I think you should look again at
argMsgContext.setProperty(HTTPConstants.RESPONSE_CODE) little more
closely. It 'feels' like the correct way to do it, don't you think?
Perhaps you can call it in a different place than where you do now?

Anyway, in Axis1, you can register handlers in a client-config.wsdd
file, or do it programmatically, using code like this: 
private static void registerClientHandlers(PaGWebService_ServiceLocator
locator) {
  try {
   //======================================
   //Register Clientside Handler
   //======================================
   //PaGWebService_ServiceLocator locator = new
PaGWebService_ServiceLocator();
   javax.xml.namespace.QName portName = new
javax.xml.namespace.QName("sessions", "PaGWebService");

   javax.xml.rpc.handler.HandlerRegistry hr =
locator.getHandlerRegistry();
   java.util.List handlerChain = hr.getHandlerChain(portName);
   javax.xml.rpc.handler.HandlerInfo hInfo = new
javax.xml.rpc.handler.HandlerInfo();
   hInfo.setHandlerClass(client.ClientSideHandler.class);
   handlerChain.add(hInfo);
  }
  catch (Exception e) {
    System.out.println("Caught an exception when registering the
clientside handler: " + e.getMessage());
  }
}
Obviously, you need to supply the correct locator object and get the
QName correct. I don't know if this is the exact way to do it in Axis2,
though.
Sorry I couldn't help more,
-jeff

 

-----Original Message-----
From: Guido Wischrop [mailto:wischrop@googlemail.com] 
Sent: Thursday, August 16, 2007 5:24 AM
To: axis-user@ws.apache.org
Subject: Re: Modify servers HTTP response from "202 Accepted" to "200
OK"

Hi Jeff,
thanks for the quick reply. Your suggestion raised some more questions:
1) At which phase do we have to register the handler? We tried it after
the PostDispatch phase, but we are not sure if this is correct, because
we don't know at which point the HTTP response code is set. If it is
set in a flowComplete() method, it might be the wrong phase.

2) How do we get the HTTP headers? We tried
argMsgContext.getProperty(HTTPConstants.MC_HTTP_STATUS_CODE) and
argMsgContext.getProperty(HTTPConstants.RESPONSE_CODE) - but both do
return null. Also directly setting the response code in the
HttpServletResponse does not work.

Thanks for your help,
Guido

On 8/15/07, Walker, Jeff <Jeff.Walker@fmr.com> wrote:
> You might try writing a handler class that gets called on the outgoing
> response. If you correctly register the handler class, it will get
> called after the web service has formulated the response and sent it
> out.
>
> You can get the HTTP headers of the response from the MessageContext
> passed to your invoke() in the handler class, I think, and then you
> could try editing the appropriate http header. Once you do that,
return
> true from invoke() and hopefully the adjusted http header with '200
OK'
> will go back to your client.
> Just a suggestion,
> -jeff
>
>
> -----Original Message-----
> From: Guido Wischrop [mailto:wischrop@googlemail.com]
> Sent: Wednesday, August 15, 2007 12:08 PM
> To: axis-user@ws.apache.org
> Subject: Modify servers HTTP response from "202 Accepted" to "200 OK"
>
> Hello,
> we are providing a service for an old external client. This client
> expects a 200 OK HTTP response for a successful delivered message. We
> implemented the service by using axis2 1.2 and unfortunately it
> answers with a "202 Accepted".
> We tried to set the response code in our MessageReceiver like this:
>
> HttpServletResponse response = (HttpServletResponse)
>
MessageContext.getCurrentMessageContext().getProperty(HTTPConstants.MC_H
> TTP_SERVLETRESPONSE);
> if (response !=null ) {
>     response.setStatus(HttpServletResponse.SC_OK);
> }
>
> But this doesn't work. Is it possible to change the response code in
> some other way?
>
> Thanks for any help,
> Guido
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Mime
View raw message