Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 53186 invoked from network); 29 Sep 2005 06:36:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 29 Sep 2005 06:36:55 -0000 Received: (qmail 14233 invoked by uid 500); 29 Sep 2005 06:36:54 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 14163 invoked by uid 500); 29 Sep 2005 06:36:53 -0000 Mailing-List: contact axis-cvs-help@ws.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list axis-cvs@ws.apache.org Received: (qmail 14150 invoked by uid 500); 29 Sep 2005 06:36:53 -0000 Delivered-To: apmail-ws-axis2-cvs@ws.apache.org Received: (qmail 14147 invoked by uid 99); 29 Sep 2005 06:36:53 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 28 Sep 2005 23:36:52 -0700 Received: (qmail 53126 invoked by uid 65534); 29 Sep 2005 06:36:31 -0000 Message-ID: <20050929063631.53125.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r292393 - /webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java Date: Thu, 29 Sep 2005 06:36:31 -0000 To: axis2-cvs@ws.apache.org From: deepal@apache.org X-Mailer: svnmailer-1.0.5 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: deepal Date: Wed Sep 28 23:36:24 2005 New Revision: 292393 URL: http://svn.apache.org/viewcvs?rev=292393&view=rev Log: Handling transport errors HTTP 500 Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java Modified: webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java?rev=292393&r1=292392&r2=292393&view=diff ============================================================================== --- webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java (original) +++ webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java Wed Sep 28 23:36:24 2005 @@ -56,9 +56,9 @@ private boolean chuncked = false; private String httpVersion = HTTPConstants.HEADER_PROTOCOL_11; - + int soTimeout = HTTPConstants.DEFAULT_SO_TIMEOUT; - + int connectionTimeout = HTTPConstants.DEFAULT_CONNECTION_TIMEOUT; public static final String HTTP_METHOD = "HTTP_METHOD"; @@ -70,7 +70,7 @@ protected OMOutputImpl omOutput = new OMOutputImpl(); protected Log log = LogFactory.getLog(getClass().getName()); - + public CommonsHTTPTransportSender() { } //default @@ -98,16 +98,16 @@ omOutput.setDoOptimize(msgContext.isDoingMTOM()); omOutput.setCharSetEncoding(charSetEnc); - + //Check for the REST behaviour, if you desire rest beahaviour //put a at the // server.xml/client.xml file EndpointReference epr = null; if (msgContext.getTo() != null && !AddressingConstants.Submission.WSA_ANONYMOUS_URL.equals( - msgContext.getTo().getAddress()) + msgContext.getTo().getAddress()) && !AddressingConstants.Final.WSA_ANONYMOUS_URL.equals( - msgContext.getTo().getAddress())) { + msgContext.getTo().getAddress())) { epr = msgContext.getTo(); } @@ -258,8 +258,8 @@ if (!doingMTOM) { XMLStreamWriter outputWriter = XMLOutputFactory.newInstance() - .createXMLStreamWriter(bytesOut, - charSetEnc); + .createXMLStreamWriter(bytesOut, + charSetEnc); OMOutputImpl output = new OMOutputImpl(outputWriter); output.setCharSetEncoding(charSetEnc); element.serialize(output); @@ -319,29 +319,29 @@ } public long getContentLength() { - try { - if (doingMTOM) { //chagened - if (chuncked) { - return -1; - } else { - if (bytes == null) { - bytes = writeBytes(); - } - return bytes.length; + try { + if (doingMTOM) { //chagened + if (chuncked) { + return -1; + } else { + if (bytes == null) { + bytes = writeBytes(); } + return bytes.length; + } + } else { + if (chuncked) { + return -1; } else { - if (chuncked) { - return -1; - } else { - if (bytes == null) { - bytes = writeBytes(); - } - return bytes.length; + if (bytes == null) { + bytes = writeBytes(); } + return bytes.length; } - } catch (AxisFault e) { - return -1; } + } catch (AxisFault e) { + return -1; + } } public String getContentType() { @@ -390,7 +390,7 @@ HTTPConstants.HEADER_TRANSFER_ENCODING); if (transferEncoding != null && HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED.equals( - transferEncoding.getValue())) { + transferEncoding.getValue())) { this.chuncked = true; } } else if ( @@ -399,31 +399,31 @@ } else { throw new AxisFault( "Parameter " - + HTTPConstants.PROTOCOL_VERSION - + " Can have values only HTTP/1.0 or HTTP/1.1"); + + HTTPConstants.PROTOCOL_VERSION + + " Can have values only HTTP/1.0 or HTTP/1.1"); } } //Get the timeout values from the configuration try { - Parameter tempSoTimeoutParam = transportOut - .getParameter(HTTPConstants.SO_TIMEOUT); - Parameter tempConnTimeoutParam = transportOut - .getParameter(HTTPConstants.CONNECTION_TIMEOUT); - - if (tempSoTimeoutParam != null) { - soTimeout = Integer.parseInt((String) tempSoTimeoutParam - .getValue()); - } - - if (tempConnTimeoutParam != null) { - connectionTimeout = Integer - .parseInt((String) tempConnTimeoutParam.getValue()); - } - + Parameter tempSoTimeoutParam = transportOut + .getParameter(HTTPConstants.SO_TIMEOUT); + Parameter tempConnTimeoutParam = transportOut + .getParameter(HTTPConstants.CONNECTION_TIMEOUT); + + if (tempSoTimeoutParam != null) { + soTimeout = Integer.parseInt((String) tempSoTimeoutParam + .getValue()); + } + + if (tempConnTimeoutParam != null) { + connectionTimeout = Integer + .parseInt((String) tempConnTimeoutParam.getValue()); + } + } catch (NumberFormatException nfe) { - //If there's a problem log it and use the default values - log.error("Invalid timeout value format: not a number", nfe); + //If there's a problem log it and use the default values + log.error("Invalid timeout value format: not a number", nfe); } } @@ -438,10 +438,10 @@ httpClient = new HttpClient(); //hostConfig handles the socket functions.. //HostConfiguration hostConfig = getHostConfiguration(msgContext, url); - + //Get the timeout values set in the runtime getTimoutValues(msgContext); - + // SO_TIMEOUT -- timeout for blocking reads httpClient.getHttpConnectionManager().getParams().setSoTimeout(soTimeout); // timeout for initial connection @@ -498,7 +498,7 @@ HTTPConstants.HEADER_EXPECT_100_Continue); } } - + this.httpClient.executeMethod(postMethod); if (postMethod.getStatusCode() == HttpStatus.SC_OK) { @@ -515,6 +515,15 @@ if(value.indexOf(SOAP11Constants.SOAP_11_CONTENT_TYPE)>=0|| value.indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE) >=0){ processResponse(postMethod, msgContext); + } else { + /** + * if the content type is text/html;charset=utf-8 + */ + throw new AxisFault( + Messages.getMessage( + "transportError", + String.valueOf(postMethod.getStatusCode()), + postMethod.getResponseBodyAsString())); } } }else{ @@ -533,27 +542,27 @@ * teh default values or the values set by teh configuration will be used * @param msgContext */ - private void getTimoutValues(MessageContext msgContext) { - try { - // If the SO_TIMEOUT of CONNECTION_TIMEOUT is set by dynamically the - // override the static config - Integer tempSoTimeoutProperty = (Integer) msgContext - .getProperty(HTTPConstants.SO_TIMEOUT); - Integer tempConnTimeoutProperty = (Integer) msgContext - .getProperty(HTTPConstants.CONNECTION_TIMEOUT); - - if (tempSoTimeoutProperty != null) { - connectionTimeout = tempSoTimeoutProperty.intValue(); - } - - if (tempConnTimeoutProperty != null) { - connectionTimeout = tempConnTimeoutProperty.intValue(); - } - } catch (NumberFormatException nfe) { - //If there's a problem log it and use the default values - log.error("Invalid timeout value format: not a number", nfe); - } - } + private void getTimoutValues(MessageContext msgContext) { + try { + // If the SO_TIMEOUT of CONNECTION_TIMEOUT is set by dynamically the + // override the static config + Integer tempSoTimeoutProperty = (Integer) msgContext + .getProperty(HTTPConstants.SO_TIMEOUT); + Integer tempConnTimeoutProperty = (Integer) msgContext + .getProperty(HTTPConstants.CONNECTION_TIMEOUT); + + if (tempSoTimeoutProperty != null) { + connectionTimeout = tempSoTimeoutProperty.intValue(); + } + + if (tempConnTimeoutProperty != null) { + connectionTimeout = tempConnTimeoutProperty.intValue(); + } + } catch (NumberFormatException nfe) { + //If there's a problem log it and use the default values + log.error("Invalid timeout value format: not a number", nfe); + } + } private void processResponse(HttpMethodBase httpMethod, MessageContext msgContext) throws IOException { obatainHTTPHeaderInformation(httpMethod, msgContext); @@ -579,7 +588,7 @@ getMethod.setRequestHeader( HTTPConstants.HEADER_CONTENT_TYPE, "text/xml; charset=" - + MessageContext.DEFAULT_CHAR_SET_ENCODING); + + MessageContext.DEFAULT_CHAR_SET_ENCODING); else getMethod.setRequestHeader( HTTPConstants.HEADER_CONTENT_TYPE, @@ -591,7 +600,7 @@ //Get the timeout values set in the runtime getTimoutValues(msgContext); - + // SO_TIMEOUT -- timeout for blocking reads httpClient.getHttpConnectionManager().getParams().setSoTimeout(soTimeout); // timeout for initial connection @@ -619,7 +628,7 @@ Header contenttypeHheader = getMethod.getResponseHeader( HTTPConstants.HEADER_CONTENT_TYPE); - String value = contenttypeHheader.getValue(); + String value = contenttypeHheader.getValue(); if(value != null){ if(value.indexOf(SOAP11Constants.SOAP_11_CONTENT_TYPE)>=0|| value.indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE) >=0){