0

I'm new in .NET Core. I have implemented MTOM in .NET framework by adding bindings of MTOM, now I need to implement WcfCoreMtomEncoder in my .NET Core project.

I'm little bit confused as there is no web.config in .NET Core, so where can I implement MTOM? and how?

Thanks in advance.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Noha
  • 29
  • 5

1 Answers1

0

The MtomMessageEncoderBindingElement allows .NET Core applications to communicate with WCF endpoints which support MTOM encoding.

Note: This is not a complete implementation of MTOM. It is meant as a workaround for calling existing MTOM encoded SOAP services. It consumes MTOM encoded messages, but does not perform MTOMEncoding on outbound messages. However this should be sufficent for interoperating with existing services.

You need to install the WcfCoreMtomEncoder Nuget Package: Install-Package WcfCoreMtomEncoder. And then create a custom binding:

var encoding = new MtomMessageEncoderBindingElement(new TextMessageEncodingBindingElement());
var transport = new HttpTransportBindingElement();
var customBinding = new CustomBinding(encoding, transport);

var client = new MtomEnabledServiceClient(customBinding);

For specific steps, you can refer to this link.

Chen
  • 4,499
  • 1
  • 2
  • 9
  • Thanks chen, so this function will added to client side ? not service side? – Noha Nov 28 '22 at 06:34
  • The way in the link is handled on the client side. @Noha – Chen Nov 28 '22 at 06:44
  • is their a way to do it in service side , the client send send us text/xml file content type, and we need to use MTOM but it did not accept this content type. – Noha Nov 28 '22 at 07:04
  • From another answer in the link, it seems that this method also applies to the server side. @Noha – Chen Nov 28 '22 at 07:36