client program doesn't get exception for a http 500 staus response

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

client program doesn't get exception for a http 500 staus response

sg liu
I'm working with axis2 1.5.1, and try to use it as webservice client.
when I try to invoke a oneway webservice operation, I found if the server return http 500, I didn't got any exception in client side.
but for other status code, like, http 404, I can get an exception.
I made some study on axis2 source code.
and found the logic in following method, org.apache.axis2.transport.http.HTTPSender.handleResponse(MessageContext, HttpMethodBase):

for  HttpStatus.SC_INTERNAL_SERVER_ERROR || HttpStatus.SC_BAD_REQUE
if the operation is 2 way operation, set ProcessingFault to true for income message.
but for one way operation, there is no special action, except just try to process the response.
since 1 way operation doesn't expected a response soap message, the response seems was discarded.
I want to know is there any special consideration for such behavior?
should't a exception be thrown out when response status code is 500 and operation is of  one way?
I inline the method I mentioned for convenient review.
in addition, I checked source of axis2 1.6, and found the behavior is as the same.  



     * Used to handle the HTTP Response
     *
     * @param msgContext - The MessageContext of the message
     * @param method     - The HTTP method used
     * @throws IOException - Thrown in case an exception occurs
     */
    private void handleResponse(MessageContext msgContext,
                                HttpMethodBase method) throws IOException {
        int statusCode = method.getStatusCode();
        log.trace("Handling response - " + statusCode);
        if (statusCode == HttpStatus.SC_OK) {
            processResponse(method, msgContext);
        } else if (statusCode == HttpStatus.SC_ACCEPTED) {
        } else if (statusCode == HttpStatus.SC_INTERNAL_SERVER_ERROR ||
                statusCode == HttpStatus.SC_BAD_REQUEST) {
            Header contenttypeHeader =
                    method.getResponseHeader(HTTPConstants.HEADER_CONTENT_TYPE);
            String value = null;
            if (contenttypeHeader != null) {
                value = contenttypeHeader.getValue();
            }
             OperationContext opContext = msgContext.getOperationContext();
            if(opContext!=null){
                MessageContext inMessageContext =
                        opContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
                if(inMessageContext!=null){
                    inMessageContext.setProcessingFault(true);
                }
            }
            if (value != null) {

                processResponse(method, msgContext);
            }
            //should't a exception be thrown out here in a else branch like
            //else{
                    // throw new AxisFault(Messages.getMessage("transportError", String.valueOf(statusCode),  method.getStatusText()));
            //}



            Object isTransportNonBlocking = msgContext.getProperty(
                    MessageContext.TRANSPORT_NON_BLOCKING);
            if (isTransportNonBlocking != null && (Boolean)isTransportNonBlocking) {
                throw new AxisFault(Messages.getMessage("transportError",
                        String.valueOf(statusCode),
                        method.getStatusText()));
            }
        } else {
            throw new AxisFault(Messages.getMessage("transportError",
                                                    String.valueOf(statusCode),
                                                    method.getStatusText()));
        }
    }
thanks
ysliu
Reply | Threaded
Open this post in threaded view
|

RE: client program doesn't get exception for a http 500 staus response

Martin Gainty




Date: Thu, 6 Aug 2015 17:09:07 +0800
Subject: client program doesn't get exception for a http 500 staus response
From: [hidden email]
To: [hidden email]

I'm working with axis2 1.5.1, and try to use it as webservice client.
when I try to invoke a oneway webservice operation, I found if the server return http 500, I didn't got any exception in client side.
but for other status code, like, http 404, I can get an exception.
I made some study on axis2 source code.
and found the logic in following method, org.apache.axis2.transport.http.HTTPSender.handleResponse(MessageContext, HttpMethodBase):

for  HttpStatus.SC_INTERNAL_SERVER_ERROR || HttpStatus.SC_BAD_REQUE
if the operation is 2 way operation, set ProcessingFault to true for income message.
but for one way operation, there is no special action, except just try to process the response.
since 1 way operation doesn't expected a response soap message, the response seems was discarded.
I want to know is there any special consideration for such behavior?
should't a exception be thrown out when response status code is 500 and operation is of  one way?

MG>One way-operation in the west means as you soon as request arrives at destination you never return
MG>Is One-way-operation classified differently in the East?

I inline the method I mentioned for convenient review.
in addition, I checked source of axis2 1.6, and found the behavior is as the same.  



     * Used to handle the HTTP Response
     *
     * @param msgContext - The MessageContext of the message
     * @param method     - The HTTP method used
     * @throws IOException - Thrown in case an exception occurs
     */
    private void handleResponse(MessageContext msgContext,
                                HttpMethodBase method) throws IOException {
        int statusCode = method.getStatusCode();
        log.trace("Handling response - " + statusCode);
        if (statusCode == HttpStatus.SC_OK) {
            processResponse(method, msgContext);
        } else if (statusCode == HttpStatus.SC_ACCEPTED) {
        } else if (statusCode == HttpStatus.SC_INTERNAL_SERVER_ERROR ||
                statusCode == HttpStatus.SC_BAD_REQUEST) {
            Header contenttypeHeader =
                    method.getResponseHeader(HTTPConstants.HEADER_CONTENT_TYPE);
            String value = null;
            if (contenttypeHeader != null) {
                value = contenttypeHeader.getValue();
            }
             OperationContext opContext = msgContext.getOperationContext();
            if(opContext!=null){
                MessageContext inMessageContext =
                        opContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
                if(inMessageContext!=null){
                    inMessageContext.setProcessingFault(true);
                }
            }
            if (value != null) {

                processResponse(method, msgContext);
            }
            //should't a exception be thrown out here in a else branch like
            //else{
                    // throw new AxisFault(Messages.getMessage("transportError", String.valueOf(statusCode),  method.getStatusText()));
            //}



            Object isTransportNonBlocking = msgContext.getProperty(
                    MessageContext.TRANSPORT_NON_BLOCKING);
            if (isTransportNonBlocking != null && (Boolean)isTransportNonBlocking) {
                throw new AxisFault(Messages.getMessage("transportError",
                        String.valueOf(statusCode),
                        method.getStatusText()));
            }
        } else {
            throw new AxisFault(Messages.getMessage("transportError",
                                                    String.valueOf(statusCode),
                                                    method.getStatusText()));
        }
    }
thanks
ysliu
Reply | Threaded
Open this post in threaded view
|

Re: client program doesn't get exception for a http 500 staus response

sg liu
one way operation also send the soap request through http. A response of the http request is returned.
the response may be a http 202 that represent the server side accept the request.
it also could be http404 or http 500, that represent the server side didn't accept the request.
for axis2 work as client to call one way operation.
when http response is 404, the client will get an "transport error" exception.
but when http response is 500, the client didn't get the "transport error".
I want to know the reason for the different behavior.
it is obvious not related with "west" or "east".
ysliu

On Thu, Aug 6, 2015 at 7:00 PM, Martin Gainty <[hidden email]> wrote:




Date: Thu, 6 Aug 2015 17:09:07 +0800
Subject: client program doesn't get exception for a http 500 staus response
From: [hidden email]
To: [hidden email]

I'm working with axis2 1.5.1, and try to use it as webservice client.
when I try to invoke a oneway webservice operation, I found if the server return http 500, I didn't got any exception in client side.
but for other status code, like, http 404, I can get an exception.
I made some study on axis2 source code.
and found the logic in following method, org.apache.axis2.transport.http.HTTPSender.handleResponse(MessageContext, HttpMethodBase):

for  HttpStatus.SC_INTERNAL_SERVER_ERROR || HttpStatus.SC_BAD_REQUE
if the operation is 2 way operation, set ProcessingFault to true for income message.
but for one way operation, there is no special action, except just try to process the response.
since 1 way operation doesn't expected a response soap message, the response seems was discarded.
I want to know is there any special consideration for such behavior?
should't a exception be thrown out when response status code is 500 and operation is of  one way?

MG>One way-operation in the west means as you soon as request arrives at destination you never return
MG>Is One-way-operation classified differently in the East?

I inline the method I mentioned for convenient review.
in addition, I checked source of axis2 1.6, and found the behavior is as the same.  



     * Used to handle the HTTP Response
     *
     * @param msgContext - The MessageContext of the message
     * @param method     - The HTTP method used
     * @throws IOException - Thrown in case an exception occurs
     */
    private void handleResponse(MessageContext msgContext,
                                HttpMethodBase method) throws IOException {
        int statusCode = method.getStatusCode();
        log.trace("Handling response - " + statusCode);
        if (statusCode == HttpStatus.SC_OK) {
            processResponse(method, msgContext);
        } else if (statusCode == HttpStatus.SC_ACCEPTED) {
        } else if (statusCode == HttpStatus.SC_INTERNAL_SERVER_ERROR ||
                statusCode == HttpStatus.SC_BAD_REQUEST) {
            Header contenttypeHeader =
                    method.getResponseHeader(HTTPConstants.HEADER_CONTENT_TYPE);
            String value = null;
            if (contenttypeHeader != null) {
                value = contenttypeHeader.getValue();
            }
             OperationContext opContext = msgContext.getOperationContext();
            if(opContext!=null){
                MessageContext inMessageContext =
                        opContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
                if(inMessageContext!=null){
                    inMessageContext.setProcessingFault(true);
                }
            }
            if (value != null) {

                processResponse(method, msgContext);
            }
            //should't a exception be thrown out here in a else branch like
            //else{
                    // throw new AxisFault(Messages.getMessage("transportError", String.valueOf(statusCode),  method.getStatusText()));
            //}



            Object isTransportNonBlocking = msgContext.getProperty(
                    MessageContext.TRANSPORT_NON_BLOCKING);
            if (isTransportNonBlocking != null && (Boolean)isTransportNonBlocking) {
                throw new AxisFault(Messages.getMessage("transportError",
                        String.valueOf(statusCode),
                        method.getStatusText()));
            }
        } else {
            throw new AxisFault(Messages.getMessage("transportError",
                                                    String.valueOf(statusCode),
                                                    method.getStatusText()));
        }
    }
thanks
ysliu

Reply | Threaded
Open this post in threaded view
|

Re: client program doesn't get exception for a http 500 staus response

sg liu
In reply to this post by Martin Gainty
one way operation also send the soap request through http. A response of the http request is returned.
the response may be a http 202 that represent the server side accept the request.
it also could be http404 or http 500, that represent the server side didn't accept the request.
for axis2 work as client to call one way operation.
when http response is 404, the client will get an "transport error" exception.
but when http response is 500, the client didn't get the "transport error".
I want to know the reason for the different behavior.
it is obvious not related with "west" or "east".
ysliu

On Thu, Aug 6, 2015 at 7:00 PM, Martin Gainty <[hidden email]> wrote:




Date: Thu, 6 Aug 2015 17:09:07 +0800
Subject: client program doesn't get exception for a http 500 staus response
From: [hidden email]
To: [hidden email]

I'm working with axis2 1.5.1, and try to use it as webservice client.
when I try to invoke a oneway webservice operation, I found if the server return http 500, I didn't got any exception in client side.
but for other status code, like, http 404, I can get an exception.
I made some study on axis2 source code.
and found the logic in following method, org.apache.axis2.transport.http.HTTPSender.handleResponse(MessageContext, HttpMethodBase):

for  HttpStatus.SC_INTERNAL_SERVER_ERROR || HttpStatus.SC_BAD_REQUE
if the operation is 2 way operation, set ProcessingFault to true for income message.
but for one way operation, there is no special action, except just try to process the response.
since 1 way operation doesn't expected a response soap message, the response seems was discarded.
I want to know is there any special consideration for such behavior?
should't a exception be thrown out when response status code is 500 and operation is of  one way?

MG>One way-operation in the west means as you soon as request arrives at destination you never return
MG>Is One-way-operation classified differently in the East?

I inline the method I mentioned for convenient review.
in addition, I checked source of axis2 1.6, and found the behavior is as the same.  



     * Used to handle the HTTP Response
     *
     * @param msgContext - The MessageContext of the message
     * @param method     - The HTTP method used
     * @throws IOException - Thrown in case an exception occurs
     */
    private void handleResponse(MessageContext msgContext,
                                HttpMethodBase method) throws IOException {
        int statusCode = method.getStatusCode();
        log.trace("Handling response - " + statusCode);
        if (statusCode == HttpStatus.SC_OK) {
            processResponse(method, msgContext);
        } else if (statusCode == HttpStatus.SC_ACCEPTED) {
        } else if (statusCode == HttpStatus.SC_INTERNAL_SERVER_ERROR ||
                statusCode == HttpStatus.SC_BAD_REQUEST) {
            Header contenttypeHeader =
                    method.getResponseHeader(HTTPConstants.HEADER_CONTENT_TYPE);
            String value = null;
            if (contenttypeHeader != null) {
                value = contenttypeHeader.getValue();
            }
             OperationContext opContext = msgContext.getOperationContext();
            if(opContext!=null){
                MessageContext inMessageContext =
                        opContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
                if(inMessageContext!=null){
                    inMessageContext.setProcessingFault(true);
                }
            }
            if (value != null) {

                processResponse(method, msgContext);
            }
            //should't a exception be thrown out here in a else branch like
            //else{
                    // throw new AxisFault(Messages.getMessage("transportError", String.valueOf(statusCode),  method.getStatusText()));
            //}



            Object isTransportNonBlocking = msgContext.getProperty(
                    MessageContext.TRANSPORT_NON_BLOCKING);
            if (isTransportNonBlocking != null && (Boolean)isTransportNonBlocking) {
                throw new AxisFault(Messages.getMessage("transportError",
                        String.valueOf(statusCode),
                        method.getStatusText()));
            }
        } else {
            throw new AxisFault(Messages.getMessage("transportError",
                                                    String.valueOf(statusCode),
                                                    method.getStatusText()));
        }
    }
thanks
ysliu