You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sa...@apache.org on 2006/01/03 09:35:42 UTC
svn commit: r365577 -
/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
Author: saminda
Date: Tue Jan 3 00:35:38 2006
New Revision: 365577
URL: http://svn.apache.org/viewcvs?rev=365577&view=rev
Log:
Added logic to handle status change at runtime of chunking. This is done due some end points does not give provision
for chunked soap message eventhough they support HTTP/1.1.
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=365577&r1=365576&r2=365577&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 Tue Jan 3 00:35:38 2006
@@ -57,61 +57,71 @@
protected Log log = LogFactory.getLog(getClass().getName());
protected String httpVersion = HTTPConstants.HEADER_PROTOCOL_11;
- private boolean chunked = false;
+ private boolean chunked = false;
int connectionTimeout = HTTPConstants.DEFAULT_CONNECTION_TIMEOUT;
public CommonsHTTPTransportSender() {
- }
+ }
public void cleanUp(MessageContext msgContext) throws AxisFault {
- HttpMethod httpMethod = (HttpMethod) msgContext.getProperty(HTTP_METHOD);
+ HttpMethod httpMethod =
+ (HttpMethod) msgContext.getProperty(HTTP_METHOD);
if (httpMethod != null) {
httpMethod.releaseConnection();
}
}
- public void init(ConfigurationContext confContext, TransportOutDescription transportOut)
+ public void init(ConfigurationContext confContext,
+ TransportOutDescription transportOut)
throws AxisFault {
// <parameter name="PROTOCOL" locked="false">HTTP/1.0</parameter> or
// <parameter name="PROTOCOL" locked="false">HTTP/1.1</parameter> is
// checked
- Parameter version = transportOut.getParameter(HTTPConstants.PROTOCOL_VERSION);
+ Parameter version =
+ transportOut.getParameter(HTTPConstants.PROTOCOL_VERSION);
if (version != null) {
if (HTTPConstants.HEADER_PROTOCOL_11.equals(version.getValue())) {
httpVersion = HTTPConstants.HEADER_PROTOCOL_11;
Parameter transferEncoding =
- transportOut.getParameter(HTTPConstants.HEADER_TRANSFER_ENCODING);
+ transportOut.getParameter(
+ HTTPConstants.HEADER_TRANSFER_ENCODING);
if ((transferEncoding != null)
- && HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED.equals(
- transferEncoding.getValue())) {
- chunked = true;
+ &&
+ HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED.equals(
+ transferEncoding.getValue())) {
+ chunked = true;
}
- } else if (HTTPConstants.HEADER_PROTOCOL_10.equals(version.getValue())) {
+ } else
+ if (HTTPConstants.HEADER_PROTOCOL_10.equals(version.getValue())) {
httpVersion = HTTPConstants.HEADER_PROTOCOL_10;
} else {
- throw new AxisFault("Parameter " + HTTPConstants.PROTOCOL_VERSION
- + " Can have values only HTTP/1.0 or HTTP/1.1");
+ throw new AxisFault(
+ "Parameter " + 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 tempSoTimeoutParam =
+ transportOut.getParameter(HTTPConstants.SO_TIMEOUT);
Parameter tempConnTimeoutParam =
transportOut.getParameter(HTTPConstants.CONNECTION_TIMEOUT);
if (tempSoTimeoutParam != null) {
- soTimeout = Integer.parseInt((String) tempSoTimeoutParam.getValue());
+ soTimeout = Integer.parseInt(
+ (String) tempSoTimeoutParam.getValue());
}
if (tempConnTimeoutParam != null) {
- connectionTimeout = Integer.parseInt((String) tempConnTimeoutParam.getValue());
+ connectionTimeout = Integer.parseInt(
+ (String) tempConnTimeoutParam.getValue());
}
} catch (NumberFormatException nfe) {
@@ -120,12 +130,13 @@
}
}
-
+
public void invoke(MessageContext msgContext) throws AxisFault {
try {
OMOutputFormat format = new OMOutputFormat();
String charSetEnc =
- (String) msgContext.getProperty(MessageContext.CHARACTER_SET_ENCODING);
+ (String) msgContext
+ .getProperty(MessageContext.CHARACTER_SET_ENCODING);
if (charSetEnc != null) {
format.setCharSetEncoding(charSetEnc);
@@ -133,7 +144,8 @@
OperationContext opctx = msgContext.getOperationContext();
if (opctx != null) {
- charSetEnc = (String) opctx.getProperty(MessageContext.CHARACTER_SET_ENCODING);
+ charSetEnc = (String) opctx
+ .getProperty(MessageContext.CHARACTER_SET_ENCODING);
}
}
@@ -154,14 +166,17 @@
// that now.
EndpointReference epr = null;
String transportURL =
- (String) msgContext.getProperty(MessageContextConstants.TRANSPORT_URL);
+ (String) msgContext
+ .getProperty(MessageContextConstants.TRANSPORT_URL);
if (transportURL != null) {
epr = new EndpointReference(transportURL);
} else if ((msgContext.getTo() != null)
&& !AddressingConstants.Submission.WSA_ANONYMOUS_URL
- .equals(msgContext.getTo().getAddress()) && !AddressingConstants.Final
- .WSA_ANONYMOUS_URL.equals(msgContext.getTo().getAddress())) {
+ .equals(msgContext.getTo().getAddress()) &&
+ !AddressingConstants.Final
+ .WSA_ANONYMOUS_URL
+ .equals(msgContext.getTo().getAddress())) {
epr = msgContext.getTo();
}
@@ -184,14 +199,16 @@
}
if (epr != null) {
- writeMessageWithCommons(msgContext, epr, dataOut,format);
+ writeMessageWithCommons(msgContext, epr, dataOut, format);
} else {
OutputStream out =
- (OutputStream) msgContext.getProperty(MessageContext.TRANSPORT_OUT);
+ (OutputStream) msgContext
+ .getProperty(MessageContext.TRANSPORT_OUT);
if (msgContext.isServerSide()) {
OutTransportInfo transportInfo =
- (OutTransportInfo) msgContext.getProperty(Constants.OUT_TRANSPORT_INFO);
+ (OutTransportInfo) msgContext
+ .getProperty(Constants.OUT_TRANSPORT_INFO);
if (transportInfo != null) {
boolean soap11 = msgContext.isSOAP11();
@@ -204,7 +221,8 @@
transportInfo.setContentType(encoding);
} else {
- throw new AxisFault(Constants.OUT_TRANSPORT_INFO + " has not been set");
+ throw new AxisFault(Constants.OUT_TRANSPORT_INFO +
+ " has not been set");
}
}
@@ -213,8 +231,9 @@
}
if (msgContext.getOperationContext() != null) {
- msgContext.getOperationContext().setProperty(Constants.RESPONSE_WRITTEN,
- Constants.VALUE_TRUE);
+ msgContext.getOperationContext()
+ .setProperty(Constants.RESPONSE_WRITTEN,
+ Constants.VALUE_TRUE);
}
} catch (XMLStreamException e) {
throw new AxisFault(e);
@@ -225,14 +244,17 @@
}
}
- public void writeMessageWithCommons(MessageContext msgContext, EndpointReference toURL,
- OMElement dataout,OMOutputFormat format)
+ public void writeMessageWithCommons(MessageContext msgContext,
+ EndpointReference toURL,
+ OMElement dataout,
+ OMOutputFormat format)
throws AxisFault {
try {
URL url = new URL(toURL.getAddress());
String soapActionString = msgContext.getSoapAction();
- if ((soapActionString == null) || (soapActionString.length() == 0)) {
+ if ((soapActionString == null) || (soapActionString.length() == 0))
+ {
soapActionString = msgContext.getWSAAction();
}
@@ -248,6 +270,11 @@
} else {
sender = new RESTSender();
}
+ if (msgContext.getProperty(MessageContextConstants.CHUNKED) != null)
+ {
+ chunked = Constants.VALUE_TRUE.equals(msgContext.getProperty(
+ MessageContextConstants.CHUNKED));
+ }
sender.setChunked(chunked);
sender.setFormat(format);
@@ -262,6 +289,7 @@
}
}
- public void writeMessageWithToOutPutStream(MessageContext msgContext, OutputStream out) {
+ public void writeMessageWithToOutPutStream(MessageContext msgContext,
+ OutputStream out) {
}
}