|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
Transfer-Encoding: Chunked, how disable ?Hi,
I need to invoke a web service on an integration server (webMethods) that doesn't support transfer-encoding : chunked... looking on the forum I noticed that it's a common problem using cxf transport... I try to use the cxf.xml to set up allowChunking = false using as following : <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sec="http://cxf.apache.org/configuration/security" xmlns:http="http://cxf.apache.org/transports/http/configuration" xmlns:jaxws="http://java.sun.com/xml/ns/jaxws" xsi:schemaLocation=" http://cxf.apache.org/configuration/security http://cxf.apache.org/schemas/configuration/security.xsd http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <http:conduit name="*.http-conduit"> <http:client AllowChunking="false"/> </http:conduit> </beans> The connector cxf is configured : <cxf:connector name="cxfConnector" configurationLocation="cxf.xml" initializeStaticBusInstance="false" /> But checking the raw http request I still found the Transfer-Encoding: chunked. Where am I wrong ? The configuration of the service is : <service name="resumeWm"> <inbound> <jms:inbound-endpoint name="job_in" queue="jobs_toResume_dev" synchronous="false"> <transformers> <jms:jmsmessage-to-object-transformer/> <mule-xml:xml-to-object-transformer/> <custom-transformer class="com.ge.oilandgas.batchrunner.transformer.BatchResponseToXml"> <trasformers> ......... </transformers> <response-transformers> <no-action-transformer/> </response-transformers> </jms:inbound-endpoint> </inbound> <echo-component></echo-component> <outbound> <pass-through-router> <cxf:outbound-endpoint enableMuleSoapHeaders="false" applyTransformersToProtocol="false" connector-ref="cxfConnector" address="http://localhost:6200/service/batch" proxy="true" synchronous="true" protocolConnector="cxfConnector"> </cxf:outbound-endpoint> </pass-through-router> </outbound> </service> Regards, Alessio |
|
|
Re: Transfer-Encoding: Chunked, how disable ?just an update, I have the same problem with mule 2.2.1 and mule 2.2.0
|
|
|
Re: Transfer-Encoding: Chunked, how disable ?I am having the same problem, did you ever figure out how to disable chunking?
--------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
|
Re: Transfer-Encoding: Chunked, how disable ?Hi Jonathan, I found a workaround, I've just posted it here
I add an service that works as protocol bridge grabbing the messages from a vm queue and using a simple http connector. Find a better solution would be nice... Regards, Alessio.
|
|
|
Re: Transfer-Encoding: Chunked, how disable ?On Mon, 8 Jun 2009 14:33:16 -0700 (PDT), palmalex <palmalex@...> wrote:
> Hi Jonathan, I found a workaround, I've just posted it > http://www.apsquare.com/palmalex/?p=68 here > > I add an service that works as protocol bridge grabbing the messages from a > vm queue and using a simple http connector. > > Find a better solution would be nice... Here is the patch for 3.x branch. With the patch, Mule automatically disable chunked transfer encoding if HTTP version of the request is 1.0. Can anyone try it? I think the problem is that current Mule implementation: * treats HTTP body as stream on both client and server side. * doesn't copy HTTP version from request to response. Index: transports/http/src/main/java/org/mule/transport/http/transformers/ObjectToHttpClientMethodRequest.java =================================================================== --- transports/http/src/main/java/org/mule/transport/http/transformers/ObjectToHttpClientMethodRequest.java (revision 15226) +++ transports/http/src/main/java/org/mule/transport/http/transformers/ObjectToHttpClientMethodRequest.java (working copy) @@ -27,9 +27,10 @@ import org.mule.transport.http.i18n.HttpMessages; import org.mule.util.StringUtils; +import java.io.ByteArrayOutputStream; +import java.io.IOException; import java.io.InputStream; import java.io.Serializable; -import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URLEncoder; import java.util.Iterator; @@ -275,9 +276,7 @@ else { // TODO we should probably set other properties here - String httpVersion = msg.getStringProperty(HttpConnector.HTTP_VERSION_PROPERTY, - HttpConstants.HTTP11); - if (HttpConstants.HTTP10.equals(httpVersion)) + if (isHttp10(msg)) { httpMethod.getParams().setVersion(HttpVersion.HTTP_1_0); } @@ -297,12 +296,13 @@ } } + protected void setupEntityMethod(Object src, String encoding, MuleMessage msg, URI uri, EntityEnclosingMethod postMethod) - throws UnsupportedEncodingException, TransformerException + throws TransformerException, IOException { // Dont set a POST payload if the body is a Null Payload. // This way client calls @@ -370,7 +370,14 @@ else if (src instanceof OutputHandler) { MuleEvent event = RequestContext.getEvent(); - postMethod.setRequestEntity(new StreamPayloadRequestEntity((OutputHandler) src, event)); + if (isHttp10(msg)) { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + ((OutputHandler) src).write(event, out); + postMethod.setRequestEntity(new ByteArrayRequestEntity((byte[]) out.toByteArray(), + mimeType)); + } else { + postMethod.setRequestEntity(new StreamPayloadRequestEntity((OutputHandler) src, event)); + } } else { @@ -468,4 +475,9 @@ return param.toString(); } } + + protected boolean isHttp10(MuleMessage msg) { + String httpVersion = msg.getStringProperty(HttpConnector.HTTP_VERSION_PROPERTY, HttpConstants.HTTP11); + return HttpConstants.HTTP10.equals(httpVersion); + } } Index: transports/http/src/main/java/org/mule/transport/http/transformers/MuleMessageToHttpResponse.java =================================================================== --- transports/http/src/main/java/org/mule/transport/http/transformers/MuleMessageToHttpResponse.java (revision 15226) +++ transports/http/src/main/java/org/mule/transport/http/transformers/MuleMessageToHttpResponse.java (working copy) @@ -14,6 +14,7 @@ import org.mule.api.config.MuleProperties; import org.mule.api.lifecycle.InitialisationException; import org.mule.api.transformer.TransformerException; +import org.mule.api.transport.OutputHandler; import org.mule.api.transport.PropertyScope; import org.mule.config.MuleManifest; import org.mule.transformer.AbstractMessageAwareTransformer; @@ -23,6 +24,7 @@ import org.mule.transport.http.HttpResponse; import org.mule.util.StringUtils; +import java.io.ByteArrayOutputStream; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Collection; @@ -179,7 +181,7 @@ status = HttpConstants.SC_INTERNAL_SERVER_ERROR; } - String version = (String) msg.getProperty(HttpConnector.HTTP_VERSION_PROPERTY, PropertyScope.INBOUND); + String version = (String) msg.getProperty(HttpConnector.HTTP_VERSION_PROPERTY); if (version == null) { version = HttpConstants.HTTP11; @@ -292,7 +294,20 @@ msg.getReplyTo().toString())); } - response.setBody(msg); + if (HttpConstants.HTTP11.equals(version)) { + response.setBody(msg); + } else { + OutputHandler outputHandler = msg.getPayload(OutputHandler.class); + if (outputHandler != null) { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + // Can we pass null here? + outputHandler.write(null, out); + response.setBody(out.toByteArray()); + } else { + response.setBody(msg); + } + } + return response; } Index: transports/http/src/main/java/org/mule/transport/http/HttpResponse.java =================================================================== --- transports/http/src/main/java/org/mule/transport/http/HttpResponse.java (revision 15226) +++ transports/http/src/main/java/org/mule/transport/http/HttpResponse.java (working copy) @@ -308,7 +308,7 @@ setBody(raw); } - private void setBody(final byte[] raw) + public void setBody(final byte[] raw) { if (!containsHeader(HttpConstants.HEADER_CONTENT_TYPE)) { Index: transports/cxf/src/test/java/org/mule/transport/cxf/CxfBasicTestCase.java =================================================================== --- transports/cxf/src/test/java/org/mule/transport/cxf/CxfBasicTestCase.java (revision 15226) +++ transports/cxf/src/test/java/org/mule/transport/cxf/CxfBasicTestCase.java (working copy) @@ -10,10 +10,15 @@ package org.mule.transport.cxf; +import java.util.HashMap; +import java.util.Map; + import org.mule.api.MuleMessage; import org.mule.module.client.MuleClient; import org.mule.module.xml.util.XMLUtils; import org.mule.tck.FunctionalTestCase; +import org.mule.transport.http.HttpConnector; +import org.mule.transport.http.HttpConstants; import org.mule.util.IOUtils; import javax.xml.transform.TransformerFactoryConfigurationError; @@ -46,8 +51,20 @@ MuleMessage result = client.send("cxf:http://localhost:63081/services/Echo?method=echo", "Hello!", null); assertEquals("Hello!", result.getPayload()); + assertEquals("chunked", result.getStringProperty(HttpConstants.HEADER_TRANSFER_ENCODING, "")); } + public void testEchoServiceHttp10() throws Exception + { + MuleClient client = new MuleClient(); + Map properties = new HashMap(); + properties.put(HttpConnector.HTTP_VERSION_PROPERTY, HttpConstants.HTTP10); + MuleMessage result = client.send("cxf:http://localhost:63081/services/Echo?method=echo", "Hello!", + properties); + assertEquals("Hello!", result.getPayload()); + assertEquals("", result.getStringProperty(HttpConstants.HEADER_TRANSFER_ENCODING, "")); + } + public void testEchoServiceSynchronous() throws Exception { MuleClient client = new MuleClient(); Index: transports/cxf/src/main/java/org/mule/transport/cxf/CxfServiceComponent.java =================================================================== --- transports/cxf/src/main/java/org/mule/transport/cxf/CxfServiceComponent.java (revision 15226) +++ transports/cxf/src/main/java/org/mule/transport/cxf/CxfServiceComponent.java (working copy) @@ -296,6 +296,9 @@ } muleResMsg.setProperty(MuleProperties.MULE_REPLY_TO_STOP_PROPERTY, "true"); + String version = muleReqMsg.getStringProperty(HttpConnector.HTTP_VERSION_PROPERTY, HttpConstants.HTTP11); + muleResMsg.setProperty(HttpConnector.HTTP_VERSION_PROPERTY, version); + return muleResMsg; } catch (MuleException e) -- Yuji Yamano OGIS International, Inc. --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
| Free embeddable forum powered by Nabble | Forum Help |