dotnet / wcf

This repo contains the client-oriented WCF libraries that enable applications built on .NET Core to communicate with WCF services.
MIT License
1.71k stars 559 forks source link

Add Mtom support in WCF runtime #1810

Closed chris5287 closed 3 years ago

chris5287 commented 7 years ago

I am getting the following error when using the Visual Studio WCF Connected Service extension for Visual Studio 2017:

Scaffolding Code ...
Error:Warning: The following Policy Assertions were not Imported:   XPath://wsdl:definitions[@targetNamespace='http://imaging.oracle/']/wsdl:binding[@name='DocumentContentServicePortBinding']
  Assertions:
    <ns1:OptimizedMimeSerialization xmlns:ns1='http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization'>..</ns1:OptimizedMimeSerialization>
Warning: Unsupported binding element type: 'System.ServiceModel.Channels.UnrecognizedAssertionsBindingElement'.
Warning: Unsupported message encoding element type: 'System.ServiceModel.Channels.MtomMessageEncodingBindingElement'. It must be one of the following types: 'System.ServiceModel.Channels.BinaryMessageEncodingBindingElement', 'System.ServiceModel.Channels.TextMessageEncodingBindingElement.'
Warning: Endpoint 'DocumentContentServicePort' at address 'http://localhost/imaging/ws/DocumentContentService' contains one or more bindings not compatible with .Net Core apps, skipping...
Error: No endpoints compatible with .Net Core apps were found.
Failed to generate service reference.

The WSDL/XSD file causing the issue: DocumentContentService.xsd.txt DocumentContentService.wsdl.txt

dotnet --info

.NET Command Line Tools (1.0.0)

Product Information:
 Version:            1.0.0
 Commit SHA-1 hash:  e53429feb4

Runtime Environment:
 OS Name:     Windows
 OS Version:  6.1.7601
 OS Platform: Windows
 RID:         win7-x64
 Base Path:   C:\Program Files\dotnet\sdk\1.0.0
hongdai commented 7 years ago

Hi Chris, this is because WCF runtime currently does not support Mtom. Potential workaround is try to disable Mtom on the service side if you have access to the service.

If your scenario needs Mtom support, please go ahead open a issue for WCF runtime to consider adding the support.

Thanks, Hong

chris5287 commented 7 years ago

Hi Hong, I'm afraid I do not have control over the server side :(

Where do I need to raise the issue to add Mtom support, or does this issue already cover it?

hongdai commented 7 years ago

I think you can rename this issue to add Mtom support in WCF runtime. We share the same git Repro.

eser commented 7 years ago

Same issue for me.

Warning: Unsupported binding element type: 'System.ServiceModel.Channels.UnrecognizedAssertionsBindingElement'.
Warning: Unsupported message encoding element type: 'System.ServiceModel.Channels.MtomMessageEncodingBindingElement'. It must be one of the following types: 'System.ServiceModel.Channels.BinaryMessageEncodingBindingElement', 'System.ServiceModel.Channels.TextMessageEncodingBindingElement.'
Warning: Endpoint 'ZPM_ITS_ORDER_soap12' at address 'http://tpsappr1.customer.sap.local:8000/sap/bc/srt/rfc/sap/zpm_its_order_detail_ws/400/zpm_its_order/zpm_its_order' contains one or more bindings not compatible with .Net Core apps, skipping...
Warning: Endpoint 'ZPM_ITS_ORDER' at address 'http://tpsappr1.customer.sap.local:8000/sap/bc/srt/rfc/sap/zpm_its_order_detail_ws/400/zpm_its_order/zpm_its_order' contains one or more bindings not compatible with .Net Core apps, skipping...
Error: No endpoints compatible with .Net Core apps were found.

Failed to generate service reference.
OkuraSt commented 7 years ago

same here @eserozvataf

Do you have any workarounds for consuming this type of SAP WS in net core?

Warning: Endpoint 'ZBWS_MAT_STOCKALMACEN' at address 'http://lcs03..local:8000/sap/bc/srt/rfc/sap/zws_mat_stockalmacen/200/zws_mat_stockalmacen/zbws_mat_stockalmacen' contains one or more bindings not compatible with .Net Core apps, skipping... Error: No endpoints compatible with .Net Core apps were found.

Failed to generate service reference.

suadev commented 7 years ago

Same here :(

felipecaputo commented 7 years ago

Hello folks! Is there any chance to get this implemented?

zhenlan commented 7 years ago

Not in a plan at this point. Please upvote if this is important. It will be helpful for future planning.

felipecaputo commented 7 years ago

I've tried to consume a java SOAP without mtom enabled, and it accepted my request, but the response came with xop/xml.

The content type multipart/related; type=\"application/xop+xml\" ... start-info=\"text/xml\" of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly

There is any way I can add a custom decoder to receive this message, while it isn't supported yet?

Kantuz001 commented 7 years ago

Same problem(

NapalmCodes commented 6 years ago

Has anyone figured out a work around? I can get the action to occur via the SOAP call but the response is what is failing. Even if I could get the string of the response (which is in the exception message) I could parse what I need out of it as a short term fix.

felipecaputo commented 6 years ago

not yet :(

dnbr2002 commented 6 years ago

We could really use some support for this and were hoping with dotnet core 2.0 it might get included. Any chance it's being added in a future release?

rezvanf commented 6 years ago

I have the same problem

I've tried to consume a java SOAP without mtom enabled, and it accepted my request, but the response came with xop/xml.

What i don't understand is at the supported features for .net core 1.0

https://github.com/dotnet/wcf/blob/master/release-notes/SupportedFeatures-v1.0.0.md

It shows message encoding for both text and binary supported.

So how do we do this please if we are consuming WCF services in our .net core apps and need message encoding of WSEncoding.Mtom

mconnew commented 6 years ago

I thought I would give some background on why this isn't a trivial task. This isn't a case of simply copying the code over. On the full framework we use HttpWebRequest for sending an HTTP request. We get the request stream from HttpWebRequest and then write the request message to it.

In .Net Core, we don't have HttpWebRequest available and so need to use HttpClient instead. This has a completely different model for sending a request, you pass it a class derived from HttpContent and HttpClient will request a stream from the HttpContent which it can read from and will subsequently write out to it's internal request stream. This meant that about 75% of the Http transport was basically a rewrite. We encapsulate the request message inside our own HttpContent class and when the request bytes are needed, we use the MessageEncoder to encode the message and then return that. This works well because the channel layer abstraction boundaries are cleanly observed.

The problem with MTOM is that how it's implemented on the full framework the clean api boundaries between the transport and MessageEncoder were trampled on by a herd of angry elk. With the reversal of data flow (HttpClient pulls from HttpContent instead of WCF pushing to HttpWebRequest's request stream), we will need to do a complete rewrite of the MTOM feature and probably refactor the current code so that HttpRequestMessage/HttpResponseMessage are the encapsulation boundary instead of HttpContent.

If I was working on this full time with no other tasks to work on, I would estimate it would take me about 2 months to get it to a preview state. We're aware there are some shortcomings in the full framework implementation such as the inability to precisely control which fields are placed into their own multi-part section and which are serialized inline so any rewrite would also have an eye to making sure we have a path to exposing a clean way to control this as it has been a major pain point for some.

Hopefully this explanation helps you understand why we haven't simply ported the feature at this point.

felipecaputo commented 6 years ago

@mconnew, first of all, thanks for your feedback about this topic. I don't know the framework too well, but with the right direction I would really like to do it, having the right direction to do it.

It seems really a complex implementation but, may more people would like to help if you can spare some time in tutoring or breaking it into small implementations we could do to take advantage of the OpenSource community?

Do you think it could be possible?

malsoft-pl commented 6 years ago

Same problem(

Does anyone know how to write it?

var myBinding = new WSHttpBinding(); myBinding.Security.Mode = SecurityMode.Transport; myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None; myBinding.MessageEncoding = WSMessageEncoding.Mtom;

ghost commented 6 years ago

I have this response from a service:

--MIMEBoundary_59f98a3b863640e46b622e5739083846dab4b1825abc60d0 Content-Type: application/xop+xml; charset=UTF-8; type="text/xml" Content-Transfer-Encoding: binary Content-ID: 0.49f98a3b863640e46b622e5739083846dab4b1825abc60d0@apache.org

--MIMEBoundary_59f98a3b863640e46b622e5739083846dab4b1825abc60d0--

1162898 2018-03-13T15:08:30.119+01:00 How can I convert it easily to an xml? I have the class created from the xsd, but the MTOM header is annoying me.....
mananchoksi007 commented 6 years ago

Receives Below Error while calling the post method on WCF service passing xml parameter

0202Unable to unmarshal XML stream. Please verify and resubmit.::Premature end of file.Invalid input

Its successfully working with .Net Framework. Is there different way to post the xml content then .Net framework soap service call?

lalenzos commented 6 years ago

Are there any news regarding ASP.NET Core and SOAP MTOM?

brux88 commented 6 years ago

are there news?

jducobu commented 6 years ago

Non news ... :( Personaly, i added a binding supported by .net core and use it

Trapulo commented 6 years ago

I moved my WS to the old .NET 4.6 and WCF :(

brux88 commented 6 years ago

I have a .net core project, I created another .net 4.5 project to be able to use mtom. this last project the amount in my project core.net. but it gives me an error:Method not found: 'Void System.ServiceModel.BasicHttpsBinding.set_MessageEncoding(System.ServiceModel.WSMessageEncoding)'.

why?

mananchoksi007 commented 6 years ago

Same, I had also put that service call in to .net Framework as .net core wont be able to handle that. Thats so disappointing

On Mon, Oct 29, 2018 at 12:39 PM brux88 notifications@github.com wrote:

I have a .net core project, I created another .net 4.5 project to be able to use mtom. this last project the amount in my project core.net. but it gives me an error:Method not found: 'Void System.ServiceModel.BasicHttpsBinding.set_MessageEncoding(System.ServiceModel.WSMessageEncoding)'.

why?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dotnet/wcf/issues/1810#issuecomment-433981569, or mute the thread https://github.com/notifications/unsubscribe-auth/AckWhyPJAJxjnqr_Reky1OEuvzINR-lvks5upy9RgaJpZM4McRio .

JohnTobia commented 5 years ago

This is one of my organizations only blockers moving to .NET Core. We have a document management platform that returns large documents using MTOM (that we have no control over). We have successfully written a wrapper using the XmlMtomReader class targeting net472. We really just need XmlMtomReader and XmlMtomWriter ported to .NET Core. I realize that the HttpClient/WCF stuff is more involved, but would it be possible just to get the underlying classes implemented?

felipecaputo commented 5 years ago

Non news ... :( Personaly, i added a binding supported by .net core and use it

@jducobu Can you share how did you did it?

cesaralc commented 5 years ago

Hi, Any update? This is a fairly important feature.

brux88 commented 5 years ago

Non news ... :( Personaly, i added a binding supported by .net core and use it

@jducobu Can you share how did you did it?

yes its possible share how did you did it?

NapalmCodes commented 5 years ago

Agreed sharing is caring :-)

jducobu commented 5 years ago

Mtom was abandonned in 2012 by microsoft because the protocol is slower than json. Instead of using Mtom binding, i use a basichttpbinding (or something like that). But for that, the service must be configured to use this binding configuration. Itks possible to change the binding in web.config file.

LokiMidgard commented 5 years ago

Unless you consume someone elses Service where you can't change any configuration.

jducobu commented 5 years ago

I understand. In my case i have chance the service provide also httpbasic supported by .net core. You can also offered a wrapper behind the wcfservice in rest in .net framework using mtom if it's the only binding the service offers. I'll do that if i'm in your situation

Trapulo commented 5 years ago

I understand that Mtom can be "dead". But interoperability is interoperability. For example, in Italy the government has created a mandatory service to manage all invoices of all country. Every company may use it. And this service is based on IBM+Java (ok, I know... sorry, we're in Italy, we like to be late) and requires Mtom. So, every ERP based on .NET cannot be in .NET Core and will require some legacy module in WCF 4 to bridge the two world.

felipecaputo commented 5 years ago

@Trapulo Not just Italy has legacy integrations that uses Mtom, here in Brazil the software that runs on some law courts that provide a mandatory integration to others law courts is mandatory and uses Mtom too.

We are having the same problem and this is the only thing that is blocking us to migrate our services.

NapalmCodes commented 5 years ago

A vendor product is our issue. We don't control the service implementation of OpenText.

cruentusmors commented 5 years ago

Trying to consume web service from peoplesoft using .net core - this needs to work

hickmanjos commented 5 years ago

It's also still widely used in the states, the IRS is still using MTOM.

(I'm currently on the path of restarting my project with .net framework)

brux88 commented 5 years ago

at today nothing news? :(

brux88 commented 5 years ago

there is a guide to be able to deserialize a mtom in aspnet core

felipecaputo commented 5 years ago

@brux88 Are you asking if there is a guide? Or telling that there is a guide because, if this guide exists, I'ld love to read it.

brux88 commented 5 years ago

@felipecaputo I'm looking for a guide, I can not believe that this issue has not been put even in the next milestone for two years, so I wanted to know if there were other ways to avoid the problem

felipecaputo commented 5 years ago

@brux88

I can not believe that this issue has not been put even in the next milestone

Me too, Mtom is old, I know, but it is entreprise level, and there is a lot of old webservices that problably will take a lot of time to be outdated and we need it

felipecaputo commented 5 years ago

Hi @Lxiamail it would be possible to have some definitions / specification about how this should be implemented and maybe the community could provide the implementation...

I really thing that this would make a lot of people really happy o>

JohnTobia commented 5 years ago

@felipecaputo see my comment above. To start, we really just need XmlMtomReader and XmlMtomWriter ported to .NET Core. I have a working solution (by all means not optimal) if those classes exist. It's at least a starting point.

felipecaputo commented 5 years ago

@JohnTobia I'll take a look when I get home today, maybe I can help and end up submitting a PR

kfrancis commented 5 years ago

@felipecaputo @JohnTobia I'd be willing to donate my time to this issue. We need this. I need a .NET Standard compatible library. How can we organize and get this done?

@JohnTobia Can you gist what you've done that works in your scenario?

naveen4854 commented 5 years ago

Any update on the Mtom support?

chrisengelsma commented 5 years ago

Doubling down on how important this feature is to those of us who are reluctantly clinging to .NET framework solely for Mtom support

tstefansson commented 5 years ago

Any update on the Mtom support?