I'm facing with a situation when my MTOM enabled WCF service is trying to parse MTOM request coming from Java client .
Incoming MTOM request:
--uuid:36b9a19b-37bc-4d67-8319-d8a9dad74ac6
Content-Type: application/xop+xml; charset=UTF-8; type="application/soap+xml"; action="sendData";
Content-Transfer-Encoding: binary
Content-ID: rootContentID
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Body>
<nsX:dataRequest
xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:nsX="http://abc.com/XYZ">
<param1>StringData1</param1>
<binaryData
xmime:contentType="application/octet-stream">
<xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="attachmentContentID"/>
</binaryData>
<param2>StringData2</param2>
</ns3:dataRequest>
</soap:Body>
</soap:Envelope>
--uuid:36b9a19b-37bc-4d67-8319-d8a9dad74ac6
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
Content-ID: attachmentContentID
---------------------------
----- binaryData
-------
---------------------------
--uuid:36b9a19b-37bc-4d67-8319-d8a9dad74ac6--
My service definition:
[ServiceContract(Namespace = "http://abc.com/XYZ")]
publicinterfaceIService1
{
[OperationContract(Action = "*")]
returnType
sendData(sendType req);
}
[MessageContract(WrapperName = "dataRequest", WrapperNamespace = "http://abc.com/XYZ")]
publicclass sendType
{
privatestring param1Field;
privatebyte[] binaryDataField;
privatestring param2Field;
[MessageBodyMember(Namespace = "")]
publicstring param1 { get { return param1Field; } set { param1Field = value; } }
[MessageBodyMember(Namespace = "")]
[System.Xml.Serialization.XmlTextAttribute(DataType = "base64Binary")]
publicbyte[] binaryData { get { return binaryDataField; } set { binaryDataField = value; } }
[MessageBodyMember(Namespace = "")]
publicstring param2 { get { return param2Field; } set { param2Field = value; } }
}
Service implementation:
publicclassService1 : IService1
{
public returnType sendData(sendType req)
{
// req.param1 = StringData1 OK
// req.param2 = StringData2 OK
// req.binaryData = null ????
}
}
And web.config definitions:
<system.serviceModel>
<serviceHostingEnvironmentaspNetCompatibilityEnabled="true"/>
<services>
<servicename="WCFMTOM.Service1"behaviorConfiguration="ServiceBehavior">
<endpointaddress="https://www.xyz.com/mtomtest/service.svc"
binding="customBinding"bindingConfiguration="mtomSoapBinding"
contract="WCFMTOM.IService1"/>
</service>
</services>
<bindings>
<customBinding>
<bindingname="mtomSoapBinding">
<mtomMessageEncodingmessageVersion="Soap12"/>
<httpsTransportmaxReceivedMessageSize="2000000000"/>
</binding>
</customBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behaviorname="ServiceBehavior">
<serviceDebugincludeExceptionDetailInFaults="True"/>
<serviceMetadatahttpsGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
And here comes the question. Inside of "sendData" method i could get the values of two parameters(req.param1,req.param2). But as you can see I couldn't get the binary value of req.binaryData field. It is null. I was expecting to see the binary data that is coming from the request. Am i missing something? What am i doing wrong?