After some debugging, I found that the root cause for this is the code in
lines 162-164 in AxisServlet. This code overrides the content-type set by
the MessageFormatters. So, the serialized response message on the wire is
invalid when enableMTOM is true on the server side. Here is the culprit code
in AxisServlet.
response.setContentType("text/xml; charset="
+ msgContext
.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING));
For example, here is one of the responses I received:
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
*Content-Type: text/xml;charset=UTF-8*
Transfer-Encoding: chunked
Content-Encoding: gzip
Vary: Accept-Encoding
Date: Tue, 04 Jan 2011 15:19:52 GMT
--MIMEBoundary_54171ca790b7b96d69703973e02d7a486e1fb748ceefd6fb
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: <[email protected]>
<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="
http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns:additionResponse
xmlns:ns="http://charitha.org
"><ns:return>244</ns:return></ns:additionResponse></soapenv:Body></soapenv:Envelope>
--MIMEBoundary_54171ca790b7b96d69703973e02d7a486e1fb748ceefd6fb--
The correct response will have the Content-Type set to something similar to
the following:
*Content-Type: multipart/related;
boundary="MIMEBoundary_826ad2cd3c9f9139ddc2e9428b810eb4137fd90930f13ff8";
type="application/xop+xml"; start="<
[email protected]>";
start-info="text/xml"*
*
*
Azeez
On Tue, Jan 4, 2011 at 7:26 PM, Afkham Azeez <[email protected]> wrote:
> Is MTOM working properly in the current Axis2 trunk?
>
> We have some services with the enableMTOM parameter set to true and when we
> invoke those services using stubs generated using WSDL2Java, we get this
> error on the client side. Basically, the client cannot process the response
> it received.
>
> com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character '-'
> (code 45) in prolog; expected '<'
> at [row,col {unknown-source}]: [1,1]
> at
> com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:648)
> at
> com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2047)
> at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1069)
> at
> org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.next(XMLStreamReaderWrapper.java:225)
> at
> org.apache.axiom.util.stax.dialect.DisallowDoctypeDeclStreamReaderWrapper.next(DisallowDoctypeDeclStreamReaderWrapper.java:34)
> at
> org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.next(XMLStreamReaderWrapper.java:225)
> at
> org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:681)
> at
> org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:214)
> at
> org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSOAPEnvelope(StAXSOAPModelBuilder.java:204)
> at
> org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init>(StAXSOAPModelBuilder.java:154)
> at
> org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init>(StAXSOAPModelBuilder.java:140)
> at
> org.apache.axis2.builder.SOAPBuilder.processDocument(SOAPBuilder.java:67)
> at
> org.apache.axis2.transport.TransportUtils.createDocumentElement(TransportUtils.java:179)
> at
> org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:145)
> at
> org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:108)
> at
> org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:67)
> at
> org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:354)
> at
> org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
> at
> org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
> at
> org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
>
>
> If enableMTOM is set to false either in the service or the relevant
> operation, the invocation returns successfully.
>
> These services & clients were working fine earlier.
>
> Any idea what could have gone wrong?
>
> Thanks
> Azeez
> *
> *
>
>
--
*Afkham Azeez*
Senior Software Architect & Senior Manager; WSO2, Inc.; http://wso2.com,
*
*
*Member; Apache Software Foundation;
**http://www.apache.org/*<http://www.apache.org/>
*
email: **[email protected]* <[email protected]>* cell: +94 77 3320919
blog: **http://blog.afkham.org* <http://blog.afkham.org>*
twitter: **http://twitter.com/afkham_azeez*<http://twitter.com/afkham_azeez>
*
linked-in: **http://lk.linkedin.com/in/afkhamazeez*
*
*
*Lean . Enterprise . Middleware*
*
*