I have a couple of other questions on here surrounding this area but they are a bit redundant now. Any answers to them would also be appreciated but this question is my main concern at the minute.
I have followed lots of examples of how MTOM/XOP works in WSE 3.0 and have set up my project exactly as it seems is required. I have a Byte array field that is designated as DataType:-base64Binary. In this I put the Byte array of the attachment I want to add. When I run the application and check the request, the data is encoded inline as base64, i.e. without the XOP Include element and associated MIME part.
My understanding of MTOM within WSE 3.0 was that, when encoding it will take any field designated as base64Binary and encode it as binary and move it to a MIME part, replacing it with an XOP Include element. That is to say, it just worked. But I have set the service, in the Reference file, to inherit Microsoft.Web.Services3.WebServicesClientProtocol
and have set the RequireMtom
flag to true, and it is still not encoding correctly.
Have I missed something here? Is there any other steps that should be implemented for this to work?
EDIT: After looking through my code for the 100th time, I am wondering if it might be due to the fact that I have to serialise the payload before running the ProcessMessage method. Does this sound like it could be a problem? The reason we have serialised is because the method we have to use accepts a "Payload" parameter which has a content property, this content property is an XMLElement property and the only way we can get this is to serialise the required class. But does this stop the MTOM recognising the data type of the base64 field and therefore not converted to binary with the MIME parts and XOP? Just really clutching at straws now.
EDIT 2: While I have a solution below, the third party company are now saying that our namespace prefixes are wrong! We have something like <q1:Attachment xmlns:q1="http://whatever" />
and they are demanding it be <s:Attachment xmlns:s="http://whatever" />
. Am I going mad or does that not matter? Is there a way I can tell it how to assign the namespace prefixes?
Microsoft.Web.Services3.WebServicesClientProtocol
instead ofSystem.Web.Services.Protocols.SoapHttpClientProtocol
. Once that change was made, everything worked fine. However, this change doesn't make a difference in my code, as I suspect it has to do with the serialisation step before invoking the method. – Metastasize