Replacing XopDocument class in .NET 4.0

503 Views Asked by At

With migration to .NET 4.0, we got rid of a lot of WSE libraries, including the XopDocument class. What is the recommended class to replace XopDocument class, which represents an XOP package that is part of an MTOM-encoded SOAP message

1

There are 1 best solutions below

0
On

Today I found your question when trying to understand how to add some attachment to SOAP message. In my requirements I have sample SOAP where <inc:Include href="cid:SOMEXML" xmlns:inc="http://www.w3.org/2004/08/xop/include"/> and I have to implement service which can consume such requests. I'm not experienced in WSE, so it's interesting for me for what purpose XopDocument was used there.
I resolved my issue using WCF configurations. I set messageEncoding="Mtom"

  <basicHttpBinding>
    <binding messageEncoding="Mtom" />
  </basicHttpBinding>

and my DataContract has byte[] property.

[DataContract]
public class RootObject
{
    [DataMember]
    public byte[] SOMEXML { get; set; }
}

In SOAP request it looks like

<xop:Include href="cid:http%3A%2F%2Ftempuri.org%2F1%2F634654497430144369" xmlns:xop="http://www.w3.org/2004/08/xop/include"/>

In general it is what I wanted to find.