Hi all,
Considering prior comments current code has been upgraded to handle
both regular streams and chunked streams for MTOM. Chunking is not given
as default. To enable chunking, user has to do the following changes to
the axis2.xml,
.....
<transportSender name="http"
class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
<parameter name="PROTOCOL" locked="xsd:false">HTTP/1.1</parameter>
<parameter name="Transfer-Encoding"
locked="xsd:false">chunked</parameter>
</transportSender>
.....
Patch for the above changes attached herewith. Someone please be kind
enough to apply it.
Thanks
Saminda
Ajith Ranabahu wrote:
I guess Saminda is stating the same thing, A similar piece of code
should be in the sender right now. my guess is we'll put an entry in
the axis2.xml (the configuration) stating which setting is to be used
as default.
On 8/23/05, *ERAN CHINTHAKA* <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>> wrote:
I'd like to see something like this.
If(doingMTOM){
// by default chunking is on
}else{
// by default chunking is off
}
But, this should be configurable through the MEPClient api.
Meaning, one
should be able to explicitly override the default settings through the
MEPClient API.
something like, mepClient.doMTOM(boolean);
-- Chinthaka
Saminda Abeyruwan wrote:
> Hi all,
>
> Studing the current code for MTOM support for Axis2, it's being
found,
> when "optimized" is on, CommonsHttpTrasnsportSender uses "chunk" as
> default. When doing interop tests, i've found that some interop end
> points couldn't handle "chunked" stream. Could we allow "chunking"
> on/off via Axis2.xml, till the policy is integrated to the system.
>
> Any thoughts...
>
> Saminda
>
>
--
Ajith Ranabahu
Index: modules/xml/src/org/apache/axis2/om/impl/MIMEOutputUtils.java
===================================================================
--- modules/xml/src/org/apache/axis2/om/impl/MIMEOutputUtils.java
(revision 239385)
+++ modules/xml/src/org/apache/axis2/om/impl/MIMEOutputUtils.java
(working copy)
@@ -52,7 +52,7 @@
rootMimeBodyPart.addHeader("content-type",
"application/xop+xml; charset=" + charSetEncoding +
- "; type=\""+SOAPContentType+";\"");
+ "; type=\""+SOAPContentType+"\"");
//change this position...
rootMimeBodyPart.addHeader("content-transfer-encoding", "binary");
rootMimeBodyPart.addHeader("content-id","<"+contentId+">");
@@ -138,7 +138,7 @@
sb.append("; ");
sb.append("start=\"<" + contentId + ">\"");
sb.append("; ");
- sb.append("start-info=\""+SOAPContentType+";\"");
+ sb.append("start-info=\""+SOAPContentType+"\""); // this
point being changed
return sb.toString();
}
Index: modules/xml/src/org/apache/axis2/om/impl/OMOutputImpl.java
===================================================================
--- modules/xml/src/org/apache/axis2/om/impl/OMOutputImpl.java (revision
239385)
+++ modules/xml/src/org/apache/axis2/om/impl/OMOutputImpl.java (working copy)
@@ -1,18 +1,18 @@
- /*
- * Copyright 2004,2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+/*
+* Copyright 2004,2005 The Apache Software Foundation.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
package org.apache.axis2.om.impl;
import org.apache.axis2.om.OMConstants;
@@ -46,7 +46,7 @@
private boolean isSoap11 = true;
/**
- * Field DEFAULT_CHAR_SET_ENCODING specifies the default
+ * Field DEFAULT_CHAR_SET_ENCODING specifies the default
* character encoding scheme to be used
*/
private static final String DEFAULT_CHAR_SET_ENCODING = "utf-8";
@@ -65,19 +65,20 @@
/**
* This creates a new OMOutputImpl with default encoding
- * @see OMOutputImpl#DEFAULT_CHAR_SET_ENCODING
+ *
* @param outStream
* @param doOptimize
* @throws XMLStreamException
* @throws FactoryConfigurationError
+ * @see OMOutputImpl#DEFAULT_CHAR_SET_ENCODING
*/
public OMOutputImpl(OutputStream outStream, boolean doOptimize)
- throws XMLStreamException, FactoryConfigurationError {
+ throws XMLStreamException, FactoryConfigurationError {
setOutputStream(outStream, doOptimize);
}
public void setOutputStream(OutputStream outStream, boolean doOptimize)
- throws XMLStreamException, FactoryConfigurationError {
+ throws XMLStreamException, FactoryConfigurationError {
this.doOptimize = doOptimize;
this.outStream = outStream;
@@ -88,37 +89,32 @@
if (doOptimize) {
bufferedSoapOutStream = new ByteArrayOutputStream();
xmlWriter =
- XMLOutputFactory.newInstance().createXMLStreamWriter(
- bufferedSoapOutStream,
- this.charSetEncoding);
+
XMLOutputFactory.newInstance().createXMLStreamWriter(bufferedSoapOutStream,
+ this.charSetEncoding);
binaryNodeList = new LinkedList();
} else {
xmlWriter =
- XMLOutputFactory.newInstance().createXMLStreamWriter(
- outStream,
- this.charSetEncoding);
+
XMLOutputFactory.newInstance().createXMLStreamWriter(outStream,
+ this.charSetEncoding);
}
}
+
public void flush() throws XMLStreamException {
xmlWriter.flush();
String SOAPContentType;
if (doOptimize) {
- if (isSoap11)
- {
+ if (isSoap11) {
SOAPContentType = SOAP11Constants.SOAP_11_CONTENT_TYPE;
- }
- else
- {
+ } else {
SOAPContentType = SOAP12Constants.SOAP_12_CONTENT_TYPE;
}
- MIMEOutputUtils.complete(
- outStream,
- bufferedSoapOutStream,
- binaryNodeList,
- getMimeBoundary(),
- getRootContentId(),
- this.charSetEncoding,SOAPContentType);
+ MIMEOutputUtils.complete(outStream,
+ bufferedSoapOutStream,
+ binaryNodeList,
+ getMimeBoundary(),
+ getRootContentId(),
+ this.charSetEncoding, SOAPContentType);
}
}
@@ -129,18 +125,14 @@
public String getContentType() {
String SOAPContentType;
if (isOptimized()) {
- if (isSoap11)
- {
+ if (isSoap11) {
SOAPContentType = SOAP11Constants.SOAP_11_CONTENT_TYPE;
- }
- else
- {
+ } else {
SOAPContentType = SOAP12Constants.SOAP_12_CONTENT_TYPE;
}
- return MIMEOutputUtils.getContentTypeForMime(
- getMimeBoundary(),
- getRootContentId(),
- this.getCharSetEncoding(),SOAPContentType);
+ return MIMEOutputUtils.getContentTypeForMime(getMimeBoundary(),
+ getRootContentId(),
+ this.getCharSetEncoding(), SOAPContentType);
} else {
StringBuffer buf = new StringBuffer();
@@ -149,7 +141,7 @@
buf.append("; charset=" + this.getCharSetEncoding());
} else {
buf.append(SOAP11Constants.SOAP_11_CONTENT_TYPE)
- .append("; charset=" + this.getCharSetEncoding());
+ .append("; charset=" + this.getCharSetEncoding());
}
return buf.toString();
}
@@ -168,10 +160,11 @@
return xmlWriter;
}
+
public String getMimeBoundary() {
if (mimeBoundary == null) {
mimeBoundary =
- "MIMEBoundary"
+ "--MIMEBoundary" // "--" being the change...
+ MIMEOutputUtils.getRandomStringOf18Characters();
}
return mimeBoundary;
@@ -180,7 +173,7 @@
public String getRootContentId() {
if (rootContentId == null) {
rootContentId =
- "0."
+ "0."
+ MIMEOutputUtils.getRandomStringOf18Characters()
+ "@apache.org";
}
@@ -190,15 +183,15 @@
public String getNextContentId() {
nextid++;
return nextid
- + "."
- + MIMEOutputUtils.getRandomStringOf18Characters()
- + "@apache.org";
+ + "."
+ + MIMEOutputUtils.getRandomStringOf18Characters()
+ + "@apache.org";
}
/**
* Returns the character set endocing scheme If the value of the
* charSetEncoding is not set then the default will be returned
- *
+ *
* @return
*/
public String getCharSetEncoding() {
@@ -239,4 +232,9 @@
public void setDoOptimize(boolean b) {
doOptimize = b;
}
+
+ //added to the code..
+ public OutputStream getOutputStream() {
+ return this.outStream;
+ }
}
Index: modules/integration/project.xml
===================================================================
--- modules/integration/project.xml (revision 239385)
+++ modules/integration/project.xml (working copy)
@@ -178,7 +178,8 @@
<exclude>**/*InteropStubTest.java</exclude>
<exclude>**org/apache/axis2/mail/*.java</exclude>
<exclude>**org/apache/axis2/soap12testing/soap12testsuite/*.java</exclude>
-
+<!-- <exclude>**/*WhitemesaR4ComplexTest.java</exclude>-->
+<!-- <exclude>**/*WhitemesaR4SimpleTest.java</exclude>-->
</excludes>
<includes>
<include>**/*Test.java</include>
@@ -223,7 +224,7 @@
<includes>
<include>**/*.jpg</include>
</includes>
- </resource>
+ </resource>
<resource>
<directory>test</directory>
<includes>
Index: modules/samples/src/sample/mtom/interop/client/InteropClientModel.java
===================================================================
--- modules/samples/src/sample/mtom/interop/client/InteropClientModel.java
(revision 239385)
+++ modules/samples/src/sample/mtom/interop/client/InteropClientModel.java
(working copy)
@@ -72,4 +72,7 @@
public void setTargetEPR(String targetEPR) {
this.targetEPR = new EndpointReference(targetEPR);
}
+ public void setInputFile(File inputFile) {
+ this.inputFile = inputFile;
+ }
}
Index:
modules/core/test/org/apache/axis2/engine/EngineWithoutPhaseResolvingTest.java
===================================================================
---
modules/core/test/org/apache/axis2/engine/EngineWithoutPhaseResolvingTest.java
(revision 239385)
+++
modules/core/test/org/apache/axis2/engine/EngineWithoutPhaseResolvingTest.java
(working copy)
@@ -17,6 +17,7 @@
package org.apache.axis2.engine;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.transport.http.CommonsHTTPTransportSender;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.MessageContext;
@@ -28,7 +29,6 @@
import org.apache.axis2.description.TransportOutDescription;
import org.apache.axis2.om.OMAbstractFactory;
import org.apache.axis2.soap.SOAPFactory;
-import org.apache.axis2.transport.http.CommonsHTTPTransportSender;
import org.apache.wsdl.WSDLConstants;
import org.apache.wsdl.WSDLService;
Index: modules/core/test/org/apache/axis2/engine/EnginePausingTest.java
===================================================================
--- modules/core/test/org/apache/axis2/engine/EnginePausingTest.java
(revision 239385)
+++ modules/core/test/org/apache/axis2/engine/EnginePausingTest.java
(working copy)
@@ -18,6 +18,7 @@
import junit.framework.TestCase;
import org.apache.axis2.AxisFault;
+import org.apache.axis2.transport.http.CommonsHTTPTransportSender;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.MessageContext;
@@ -26,7 +27,6 @@
import org.apache.axis2.handlers.AbstractHandler;
import org.apache.axis2.om.OMAbstractFactory;
import org.apache.axis2.soap.SOAPFactory;
-import org.apache.axis2.transport.http.CommonsHTTPTransportSender;
import org.apache.wsdl.WSDLService;
import javax.xml.namespace.QName;
Index:
modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
===================================================================
---
modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
(revision 239385)
+++
modules/core/src/org/apache/axis2/transport/http/CommonsHTTPTransportSender.java
(working copy)
@@ -69,14 +69,13 @@
public void invoke(MessageContext msgContext) throws AxisFault {
try {
String charSetEnc =
- (String) msgContext.getProperty(
- MessageContext.CHARACTER_SET_ENCODING);
+ (String)
msgContext.getProperty(MessageContext.CHARACTER_SET_ENCODING);
if (charSetEnc != null) {
omOutput.setCharSetEncoding(charSetEnc);
} else {
OperationContext opctx = msgContext.getOperationContext();
- if(opctx != null) {
- charSetEnc =
(String)opctx.getProperty(MessageContext.CHARACTER_SET_ENCODING);
+ if (opctx != null) {
+ charSetEnc = (String)
opctx.getProperty(MessageContext.CHARACTER_SET_ENCODING);
} else {
charSetEnc = MessageContext.DEFAULT_CHAR_SET_ENCODING;
}
@@ -90,10 +89,8 @@
// server.xml/client.xml file
EndpointReference epr = null;
if (msgContext.getTo() != null
- &&
!AddressingConstants.Submission.WSA_ANONYMOUS_URL.equals(
- msgContext.getTo().getAddress())
- && !AddressingConstants.Final.WSA_ANONYMOUS_URL.equals(
- msgContext.getTo().getAddress())) {
+ &&
!AddressingConstants.Submission.WSA_ANONYMOUS_URL.equals(msgContext.getTo().getAddress())
+ &&
!AddressingConstants.Final.WSA_ANONYMOUS_URL.equals(msgContext.getTo().getAddress()))
{
epr = msgContext.getTo();
}
@@ -109,16 +106,14 @@
writeMessageWithCommons(msgContext, epr, dataOut);
} else {
OutputStream out =
- (OutputStream) msgContext.getProperty(
- MessageContext.TRANSPORT_OUT);
+ (OutputStream)
msgContext.getProperty(MessageContext.TRANSPORT_OUT);
if (msgContext.isServerSide()) {
HTTPOutTransportInfo transportInfo =
- (HTTPOutTransportInfo) msgContext.getProperty(
- HTTPConstants.HTTPOutTransportInfo);
+ (HTTPOutTransportInfo)
msgContext.getProperty(HTTPConstants.HTTPOutTransportInfo);
if (transportInfo != null) {
omOutput.setSoap11(msgContext.isSOAP11());
transportInfo.setContentType(omOutput.getContentType());
- }else{
+ } else {
throw new AxisFault(HTTPConstants.HTTPOutTransportInfo
+ " does not set");
}
}
@@ -126,9 +121,8 @@
dataOut.serialize(omOutput);
omOutput.flush();
}
- if(msgContext.getOperationContext() != null){
- msgContext.getOperationContext().setProperty(
- Constants.RESPONSE_WRITTEN,
+ if (msgContext.getOperationContext() != null) {
+
msgContext.getOperationContext().setProperty(Constants.RESPONSE_WRITTEN,
Constants.VALUE_TRUE);
}
} catch (XMLStreamException e) {
@@ -140,16 +134,14 @@
}
}
- public void writeMessageWithToOutPutStream(
- MessageContext msgContext,
- OutputStream out) {
+ public void writeMessageWithToOutPutStream(MessageContext msgContext,
+ OutputStream out) {
}
- public void writeMessageWithCommons(
- MessageContext msgContext,
- EndpointReference toURL,
- OMElement dataout)
+ public void writeMessageWithCommons(MessageContext msgContext,
+ EndpointReference toURL,
+ OMElement dataout)
throws AxisFault {
try {
URL url = new URL(toURL.getAddress());
@@ -164,16 +156,14 @@
//supporting RESTFacility..
if (!msgContext.isDoingREST()) {
- this.transportConfigurationPOST(
- msgContext,
+ this.transportConfigurationPOST(msgContext,
dataout,
url,
soapActionString);
}
if (msgContext.isDoingREST()) {
if (msgContext.isRestThroughPOST()) {
- this.transportConfigurationPOST(
- msgContext,
+ this.transportConfigurationPOST(msgContext,
dataout,
url,
soapActionString);
@@ -190,13 +180,12 @@
}
}
- protected HostConfiguration getHostConfiguration(
- MessageContext context,
- URL targetURL) {
+
+ protected HostConfiguration getHostConfiguration(MessageContext context,
+ URL targetURL) {
//TODO cheaking wheather the host is a proxy
HostConfiguration config = new HostConfiguration();
- config.setHost(
- targetURL.getHost(),
+ config.setHost(targetURL.getHost(),
targetURL.getPort() == -1 ? 80 : targetURL.getPort());
return config;
}
@@ -214,11 +203,10 @@
private boolean doingMTOM = false;
- public AxisRequestEntity(
- OMElement element,
- boolean chuncked,
- boolean doingMTOM,
- String charSetEncoding) {
+ public AxisRequestEntity(OMElement element,
+ boolean chuncked,
+ boolean doingMTOM,
+ String charSetEncoding) {
this.element = element;
this.chuncked = chuncked;
this.doingMTOM = doingMTOM;
@@ -231,14 +219,22 @@
public byte[] writeBytes() throws AxisFault {
try {
+
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
- XMLStreamWriter outputWriter =
- XMLOutputFactory.newInstance().createXMLStreamWriter(
- bytesOut,
- charSetEnc);
- element.serialize(outputWriter);
- outputWriter.flush();
- return bytesOut.toByteArray();
+
+ if (!doingMTOM) {
+ XMLStreamWriter outputWriter =
+
XMLOutputFactory.newInstance().createXMLStreamWriter(bytesOut,
+ charSetEnc);
+ element.serialize(outputWriter);
+ outputWriter.flush();
+ return bytesOut.toByteArray();
+ } else {
+ omOutput.setOutputStream(bytesOut, true); //changed...
+ element.serialize(omOutput);
+ omOutput.flush();
+ return bytesOut.toByteArray();
+ }
} catch (XMLStreamException e) {
throw new AxisFault(e);
} catch (FactoryConfigurationError e) {
@@ -246,18 +242,33 @@
}
}
+ private void handleOMOutput(OutputStream out, boolean doingMTOM)
throws XMLStreamException {
+ omOutput.setOutputStream(out, doingMTOM);
+ element.serialize(omOutput);
+ omOutput.flush();
+ }
+
public void writeRequest(OutputStream out) throws IOException {
try {
- if (chuncked || doingMTOM) {
- omOutput.setOutputStream(out, doingMTOM);
- element.serialize(omOutput);
- omOutput.flush();
+ if (doingMTOM) { //chagened ..
+ if (chuncked) {
+ this.handleOMOutput(out,doingMTOM);
+ } else {
+ if (bytes == null) {
+ bytes = writeBytes();
+ }
+ out.write(bytes);
+ }
} else {
- if (bytes == null) {
- bytes = writeBytes();
+ if (chuncked) {
+ this.handleOMOutput(out,doingMTOM);
+ } else {
+ if (bytes == null) {
+ bytes = writeBytes();
+ }
+ out.write(bytes);
}
- out.write(bytes);
}
out.flush();
} catch (XMLStreamException e) {
@@ -271,13 +282,24 @@
public long getContentLength() {
try {
- if (chuncked || doingMTOM) {
- return -1;
+ if (doingMTOM) { //chagened
+ if (chuncked) {
+ return -1;
+ } else {
+ if (bytes == null) {
+ bytes = writeBytes();
+ }
+ return bytes.length;
+ }
} else {
- if (bytes == null) {
- bytes = writeBytes();
+ if (chuncked) {
+ return -1;
+ } else {
+ if (bytes == null) {
+ bytes = writeBytes();
+ }
+ return bytes.length;
}
- return bytes.length;
}
} catch (AxisFault e) {
return -1;
@@ -303,9 +325,8 @@
}
- public void init(
- ConfigurationContext confContext,
- TransportOutDescription transportOut)
+ public void init(ConfigurationContext confContext,
+ TransportOutDescription transportOut)
throws AxisFault {
//<parameter name="PROTOCOL" locked="xsd:false">HTTP/1.0</parameter> or
//<parameter name="PROTOCOL" locked="xsd:false">HTTP/1.1</parameter> is
@@ -316,19 +337,16 @@
if (HTTPConstants.HEADER_PROTOCOL_11.equals(version.getValue())) {
this.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())) {
+ &&
HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED.equals(transferEncoding.getValue()))
{
this.chuncked = true;
}
} else if (
HTTPConstants.HEADER_PROTOCOL_10.equals(version.getValue())) {
this.httpVersion = HTTPConstants.HEADER_PROTOCOL_10;
} else {
- throw new AxisFault(
- "Parameter "
+ throw new AxisFault("Parameter "
+ HTTPConstants.PROTOCOL_VERSION
+ " Can have values only HTTP/1.0 or HTTP/1.1");
}
@@ -336,11 +354,10 @@
}
- private void transportConfigurationPOST(
- MessageContext msgContext,
- OMElement dataout,
- URL url,
- String soapActionString)
+ private void transportConfigurationPOST(MessageContext msgContext,
+ OMElement dataout,
+ URL url,
+ String soapActionString)
throws MalformedURLException, AxisFault, IOException {
//execuite the HtttpMethodBase - a connection manager can be given for
handle multiple
@@ -359,29 +376,24 @@
msgContext.setProperty(HTTP_METHOD, postMethod);
String charEncoding =
- (String) msgContext.getProperty(
- MessageContext.CHARACTER_SET_ENCODING);
- if(charEncoding == null){
+ (String)
msgContext.getProperty(MessageContext.CHARACTER_SET_ENCODING);
+ if (charEncoding == null) {
charEncoding = MessageContext.DEFAULT_CHAR_SET_ENCODING;
}
- postMethod.setRequestEntity(
- new AxisRequestEntity(
- dataout,
- chuncked,
- msgContext.isDoingMTOM(),
- charEncoding));
+ postMethod.setRequestEntity(new AxisRequestEntity(dataout,
+ chuncked,
+ msgContext.isDoingMTOM(),
+ charEncoding));
if (!httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_10)
&& chuncked) {
postMethod.setContentChunked(true);
}
- postMethod.setRequestHeader(
- HTTPConstants.HEADER_USER_AGENT,
+ postMethod.setRequestHeader(HTTPConstants.HEADER_USER_AGENT,
"Axis/2.0");
if (!msgContext.isDoingREST()) {
- postMethod.setRequestHeader(
- HTTPConstants.HEADER_SOAP_ACTION,
+ postMethod.setRequestHeader(HTTPConstants.HEADER_SOAP_ACTION,
soapActionString);
}
postMethod.setRequestHeader(HTTPConstants.HEADER_HOST, url.getHost());
@@ -389,16 +401,13 @@
if (httpVersion.equals(HTTPConstants.HEADER_PROTOCOL_10)) {
//postMethod.setHttp11(false); todo method to findout the
transport version...
//allowing keep-alive for 1.0
- postMethod.setRequestHeader(
- HTTPConstants.HEADER_CONNECTION,
+ postMethod.setRequestHeader(HTTPConstants.HEADER_CONNECTION,
HTTPConstants.HEADER_CONNECTION_KEEPALIVE);
} else {
// allowing keep-alive for 1.1
- postMethod.setRequestHeader(
- HTTPConstants.HEADER_CONNECTION,
+ postMethod.setRequestHeader(HTTPConstants.HEADER_CONNECTION,
HTTPConstants.HEADER_CONNECTION_KEEPALIVE);
- postMethod.setRequestHeader(
- HTTPConstants.HEADER_EXPECT,
+ postMethod.setRequestHeader(HTTPConstants.HEADER_EXPECT,
HTTPConstants.HEADER_EXPECT_100_Continue);
}
}
@@ -409,24 +418,21 @@
processResponse(postMethod, msgContext);
} else if (postMethod.getStatusCode() == HttpStatus.SC_ACCEPTED) {
return;
- } else if (postMethod.getStatusCode() ==
HttpStatus.SC_INTERNAL_SERVER_ERROR){
+ } else if (postMethod.getStatusCode() ==
HttpStatus.SC_INTERNAL_SERVER_ERROR) {
- Header contenttypeHheader = postMethod.getResponseHeader(
- HTTPConstants.HEADER_CONTENT_TYPE);
+ Header contenttypeHheader =
postMethod.getResponseHeader(HTTPConstants.HEADER_CONTENT_TYPE);
String value = contenttypeHheader.getValue();
- if(value != null){
- if(value.indexOf(SOAP11Constants.SOAP_11_CONTENT_TYPE)>=0||
- value.indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE)
>=0){
+ if (value != null) {
+ if (value.indexOf(SOAP11Constants.SOAP_11_CONTENT_TYPE) >= 0 ||
+ value.indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE) >=
0) {
processResponse(postMethod, msgContext);
}
}
- }else{
- throw new AxisFault(
- Messages.getMessage(
- "transportError",
- String.valueOf(postMethod.getStatusCode()),
- postMethod.getResponseBodyAsString()));
+ } else {
+ throw new AxisFault(Messages.getMessage("transportError",
+ String.valueOf(postMethod.getStatusCode()),
+ postMethod.getResponseBodyAsString()));
}
}
@@ -435,11 +441,9 @@
obatainHTTPHeaderInformation(httpMethod, msgContext);
InputStream in = httpMethod.getResponseBodyAsStream();
if (in == null) {
- throw new AxisFault(
- Messages.getMessage("canNotBeNull", "InputStream"));
+ throw new AxisFault(Messages.getMessage("canNotBeNull",
"InputStream"));
}
- msgContext.getOperationContext().setProperty(
- MessageContext.TRANSPORT_IN,
+
msgContext.getOperationContext().setProperty(MessageContext.TRANSPORT_IN,
in);
}
@@ -449,16 +453,13 @@
getMethod.setPath(url.getFile());
String charEncoding =
- (String) msgContext.getProperty(
- MessageContext.CHARACTER_SET_ENCODING);
+ (String)
msgContext.getProperty(MessageContext.CHARACTER_SET_ENCODING);
if (charEncoding == null) //Default encoding scheme
- getMethod.setRequestHeader(
- HTTPConstants.HEADER_CONTENT_TYPE,
+ getMethod.setRequestHeader(HTTPConstants.HEADER_CONTENT_TYPE,
"text/xml; charset="
+ MessageContext.DEFAULT_CHAR_SET_ENCODING);
else
- getMethod.setRequestHeader(
- HTTPConstants.HEADER_CONTENT_TYPE,
+ getMethod.setRequestHeader(HTTPConstants.HEADER_CONTENT_TYPE,
"text/xml; charset=" + charEncoding);
this.httpClient = new HttpClient();
@@ -482,34 +483,32 @@
// in);
} else if (getMethod.getStatusCode() == HttpStatus.SC_ACCEPTED) {
return;
- }else if (getMethod.getStatusCode() ==
HttpStatus.SC_INTERNAL_SERVER_ERROR){
+ } else if (getMethod.getStatusCode() ==
HttpStatus.SC_INTERNAL_SERVER_ERROR) {
- Header contenttypeHheader = getMethod.getResponseHeader(
- HTTPConstants.HEADER_CONTENT_TYPE);
+ Header contenttypeHheader =
getMethod.getResponseHeader(HTTPConstants.HEADER_CONTENT_TYPE);
- String value = contenttypeHheader.getValue();
- if(value != null){
- if(value.indexOf(SOAP11Constants.SOAP_11_CONTENT_TYPE)>=0||
- value.indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE)
>=0){
+ String value = contenttypeHheader.getValue();
+ if (value != null) {
+ if (value.indexOf(SOAP11Constants.SOAP_11_CONTENT_TYPE) >= 0 ||
+ value.indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE) >=
0) {
processResponse(getMethod, msgContext);
}
}
- }else{
- throw new AxisFault(
- Messages.getMessage(
- "transportError",
- String.valueOf(getMethod.getStatusCode()),
- getMethod.getResponseBodyAsString()));
+ } else {
+ throw new AxisFault(Messages.getMessage("transportError",
+ String.valueOf(getMethod.getStatusCode()),
+ getMethod.getResponseBodyAsString()));
}
}
/**
* Collect the HTTP header information and set them in the message context
+ *
* @param method
* @param msgContext
*/
- private void obatainHTTPHeaderInformation(HttpMethodBase
method,MessageContext msgContext) {
+ private void obatainHTTPHeaderInformation(HttpMethodBase method,
MessageContext msgContext) {
Header header =
method.getResponseHeader(HTTPConstants.HEADER_CONTENT_TYPE);
if (header != null) {
@@ -519,20 +518,17 @@
.getParameterByName(HTTPConstants.CHAR_SET_ENCODING);
if (headers[i]
.getName()
- .equalsIgnoreCase(
-
HTTPConstants.HEADER_ACCEPT_MULTIPART_RELATED)) {
+
.equalsIgnoreCase(HTTPConstants.HEADER_ACCEPT_MULTIPART_RELATED)) {
OperationContext opContext =
msgContext.getOperationContext();
if (opContext != null) {
- opContext.setProperty(
- HTTPConstants.MTOM_RECIVED_CONTENT_TYPE,
+
opContext.setProperty(HTTPConstants.MTOM_RECIVED_CONTENT_TYPE,
header.getValue());
}
} else if (charsetEnc != null) {
msgContext
- .setProperty(
- MessageContext.CHARACTER_SET_ENCODING,
+ .setProperty(MessageContext.CHARACTER_SET_ENCODING,
charsetEnc);
}
}