For one thing, you have to enable MTOM in Axis2 as well. Find your axis2.xml configuration file (WEB-INF/conf/axis2.xml) and adjust the following setting:
<axisconfig name="AxisJava2.0">
<!-- ================================================= -->
<!-- Parameters -->
<!-- ================================================= -->
.../...
<parameter name="enableMTOM">true</parameter>
.../...
</axisconfig>
Wihthout this, Axis will not handle MTOM at all and the client will be very confused.
Switching to XOP/MTOM means switching to multipart-mime as well, and your client actually got a multipart-mime answer, so I suppose the Axis2 setting is OK afterall :) The fact that your client is expecting plain XML (i.e. a nice SOAP response) indicates that you have not set up MTOM on the client side.
Supposing you are using a BasicHttpBinding, enabling MTOM in WCF could be done as:
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="MySOAP11Binding"
...
messageEncoding="Mtom"
...
>
.../...
</binding>
</basicHttpBinding>
.../...
You will most certainly have to tweak the maxBufferSize, maxBufferPoolSize and maxReceivedMessageSize attributes of the binding element as well.
Alternatively, you can set this up in code:
private ServiceProxy<MyPortTypeClient, MyPortType> getClient()
{
EndpointAddress endpoint = new EndpointAddress("http://server/axis/services/My");
// The binding
BasicHttpBinding binding = new BasicHttpBinding();
binding.OpenTimeout = minutes(1);
binding.CloseTimeout = minutes(1);
binding.SendTimeout = minutes(10);
binding.ReceiveTimeout = minutes(10);
binding.MaxBufferPoolSize = Int32.MaxValue;
binding.MaxReceivedMessageSize = Int32.MaxValue;
binding.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max;
binding.MessageEncoding = WSMessageEncoding.Mtom;
if (binding is BasicHttpBinding)
{
// Also setting to streamed mode
((BasicHttpBinding)(Object)binding).TransferMode = TransferMode.Streamed;
}
binding.AllowCookies = true;
// MyPortType and MyPortTypeClient are implemented in Reference.cs, i.e. this
// code is generated by svcutil or Visual Studio from your WSDL.
MyPortTypeClient _proxy = new MyPortTypeClient(binding, endpoint);
ServiceProxy<MyPortTypeClient, MyPortType> proxy = new ServiceProxy<MyPortTypeClient, MyPortType>(_proxy);
if (!String.IsNullOrEmpty(wsUsername) && !String.IsNullOrEmpty(wsPassword))
{
UserNamePasswordClientCredential credentials = _proxy.ClientCredentials.UserName;
credentials.UserName = wsUsername;
credentials.Password = wsPassword;
}
return proxy;
}
The nice thing about doing this in code, is that you will get help form your IDE regarding what parameters can be set for any specific binding. If you switch from BasicHttpBinding to, say, WSHttpBinding you will get compilation errors for those parameters that does not match the new binding.