-
Notifications
You must be signed in to change notification settings - Fork 558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Mtom support in WCF runtime #1810
Comments
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, |
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? |
I think you can rename this issue to add Mtom support in WCF runtime. We share the same git Repro. |
Same issue for me.
|
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... Failed to generate service reference. |
Same here :( |
Hello folks! Is there any chance to get this implemented? |
Not in a plan at this point. Please upvote if this is important. It will be helpful for future planning. |
I've tried to consume a java SOAP without mtom enabled, and it accepted my request, but the response came with
There is any way I can add a custom decoder to receive this message, while it isn't supported yet? |
Same problem( |
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. |
not yet :( |
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? |
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 |
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. |
@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? |
Same problem( Does anyone know how to write it? var myBinding = new WSHttpBinding(); |
I have this response from a service: --MIMEBoundary_59f98a3b863640e46b622e5739083846dab4b1825abc60d0 --MIMEBoundary_59f98a3b863640e46b622e5739083846dab4b1825abc60d0-- <ns2:res xmlns:ns2="http:/xxxxx/v1.0/types"> How can I convert it easily to an xml? I have the class created from the xsd, but the MTOM header is annoying me..... |
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? |
Are there any news regarding ASP.NET Core and SOAP MTOM? |
@andersonaap , yes that was a mistake and I updated code. Cheers. |
Is there ETA on this one? |
Milestone |
As @RealHabix pointed out, the plan is to have this work completed for the release which aligns with the .NET 6 release. Note that we still only depend on netstandard 2.0 so we won't have a requirement of .NET 6 to use it. All currently supported versions of .NET/.NET Core support netstandard 2.0 so there shouldn't be forced to update your application to use it. This will continue to be our plan until there's a feature that requires .NET 6. |
6.0 Preview 2 is already here, but |
Any news about supporting MTOM? |
Good news, Mtom support has now been posted as a PR!! |
This is great, nice wok |
It will be available in the upcoming RC release for .NET 6. Just a reminder, WCF doesn't require .NET 6 to use our latest packages and until we have a reason to do so, our latest packages will continue to work on all supported version of .NET. We don't have a lot of code churn in the WCF client code, it's mostly adding stuff so you can have a high level of confidence in the stability of pre-release versions. |
I have installed
I have ensured that all of my NuGet packages are up-to-date (all ServiceModel packages are 4.9.0-rc1, clean, rebuild). Using dotPeek, I can open the System.Private.ServiceModel assembly and see the binding element there, in the namespace I expected. I've double-checked the source code to verify that the class is public. What am I missing? |
@bcallaghan-et, apparently I forgot to add the MtomMessageEncodingBindingElement to the reference assembly itself. You can use it by specifying it's usage with any of the various bindings. For example, BasicHttpBinding has a MessageEncoding property that allows you to specify MTOM. If you need a standalone binding element, you should be able to extract an instance from a binding and set the MessageVersion to be what you need. So for example: var binding = new BasicHttpBinding { MessageEncoding = WSMessageEncoding.Mtom };
MessageEncodingBindingElement mebe = binding.CreateBindingElements().Find<MessageEncodingBindingElement>();
mebe.MessageVersion = MessageVersion.Soap12; We'll get it added to the reference assembly before the final release. |
@mconnew Thank you for the workaround. I need to use MTOM with a custom binding, as the remote service requires both Basic auth and client certificates, and I couldn't find a way to do that with the |
But still:
How do I enable mtom encoding? |
@NicholasNoise, because the WCF packages work on any supported .NET Core/.NET release and we don't want to force upgrading to .NET 6, the MtomReader implementation has been built in to the WCF packages themselves instead of calling XmlDictionary[Reader|Writer].CreateMtomReader. This also made sense as MTOM is a SOAP only protocol so including it in the runtime and having everyone pay the cost didn't seem like the correct way to do things. This means XmlDictionaryReader.CreateMtomReader will still continue to throw an exception, but you can configure WCF to use MTOM just fine. |
@mconnew I do not use WCF itself, but to parse MTOM responses. So code that has been valid using netfx is no longer
|
@mconnew any news mate? |
Sorry I forgot to respond to your last comment. The easiest way to do this I believe is to use the MtomMessageEncodingBindingElement. This will output a Message object. Depending on how you want to parse things, I don't know how appropriate this is to your use case. Presuming you want to minimize changes elsewhere in the code, this can be converted to an XmlDocument. Here's some example code on how to do this. You might need to tweak it for your scenario a bit if the SOAP/Envelope version is different than the default. Something like this should work for you: var mtomBE = new MtomMessageEncodingBindingElement(MessageVersion.Default, Encoding.UTF8);
var encoderFactory = mtomBE.CreateMessageEncoderFactory();
var encoder = encoderFactory.Encoder;
var message = encoder.ReadMessage(stream, int.MaxValue);
var messageBufferedCopy = message.CreateBufferedCopy(int.MaxValue);
var writableMessage = messageBufferedCopy.CreateMessage();
XmlDocument doc = new XmlDocument();
using (XmlWriter xmlDocWriter = doc.CreateNavigator().AppendChild())
{
using (XmlDictionaryWriter writer = XmlDictionaryWriter.CreateDictionaryWriter(xmlDocWriter))
{
writableMessage.WriteMessage(writer);
}
} Let me know if that works for you or if you hit any problems. I couldn't test this code as I don't have an Mtom stream lying around handily to test this so it might need some tweaks. I'm curious why you are using the MtomReader directly instead of using WCF to do the work? You can use WCF in a contractless way using the IRequestChannel interface to make a request and get a reply using Message objects. Typically you would do this if the request or reply message if a little too free form for a contract definition. Going low level like this is usually a result of not knowing how to get WCF to go a little lower level. XmlDocument isn't as performant as XmlReader (which is what WCF uses to expose the body) and I wonder if there might be a better way to achieve your end goal. I often find taking a step back and looking at the original problem which is needing to be solved can lead to a simpler/cleaner solution. |
Someone Fix it? I got the issue Message Transmission Optimization Mechanism (MTOM) message encoding is not supported on this platform every time I try. |
@JoaoSaDevdotNet what do you need fixed? It's very hard to help you based on that kind of error description. Do you have an actual code sample? Maybe with a list of referenced NuGet packages and their versions? Then somebody may be able to tell you what the problem is. 👍 |
I tried to use your solution but I am getting the error The expected encoding 'utf-16LE' does not match the actual encoding 'utf-16BE'. Do you know what means? I can't be able to found nothing about it. |
Okay follow the code using var mtomMessageInMemory = new MemoryStream(xml); Here I get the error I said return (ReturningType)dataSerializer.ReadObject(reader); |
@JoaoSaDevdotNet , try replacing |
Hello @mconnew , |
Hello, @mconnew |
I am getting the following error when using the Visual Studio WCF Connected Service extension for Visual Studio 2017:
The WSDL/XSD file causing the issue:
DocumentContentService.xsd.txt
DocumentContentService.wsdl.txt
dotnet --info
The text was updated successfully, but these errors were encountered: