.NET Core 7 WCF web service : the encoding in the declaration 'ISO-8859-1' does not match the encoding of the document 'utf-8' - wcf

I am trying to communicate with a WCF service in .NET Core 7, the service responds, but in the response xml the encoding property declaration is ISO-8859-1.
This generates the error:
The encoding in the declaration 'ISO-8859-1' does not match the encoding of the document 'utf-8'
The solutions I have found on various web sites are either old or not compatible with .NET Core 7.
Any ideas?
Thanks

Related

.Net Core calling all "old" WCFs possible?

I thought I would try out .Net Core (v1.1.2) and one of the things I wondered about was if it was possible to call a WCF service written in .Net Framework 4.5.2. I am using Visual Studio 2017 and installed the Microsoft WCF Web Service Reference Provider (version 0.5.10428.1201). When I ran it, it found the service, but I got this error message when trying to generate the code:
Scaffolding Code ...
Error:Warning: Unsupported message encoding value: 'Mtom'. It must be 'Text'.
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 'WSHttpBinding_IDocumentSignService' at address 'http://xxxxxxxxxxxxx.svc' 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.
(I edited the url to http://xxxxxxxxxxxx.svc)
Does this mean that .Net Core apps can't call all WCF services yet? Will it only support a certain subset? So that if I am stuck in a world of WCF services I will have to stay away from .Net Core? Or is it simply a problem with the tooling?
I realize this has probably been asked before, but I could find no clear answer.
As explained by panagiotis's comment, you're consuming a SOAP service with MTOM encoding (what is not supported by .net Core)
Nevertheless, consuming WCF services works fine in .Net core, as long as it is not relaying on WS* bindings.
extra info here
I was also having trouble by consuming MTOM encoded SOAP services.
I explain how I fixed it here

Handling URL's encoded with ISO-8859-1 in ASP.NET Core 1.0

We are dealing with some financial institutions that send us requests encoded in ISO-8859-1. They post back to us during an authentication flow, where the query string is ISO-8859-1 encoded (some characters in the request query use Å, ä etc). How do you configure ASP.NET Core API controllers to correctly give us the decoded parameters? The default (UTF-8) obviously does not work correctly. Previous API such as
HttpUtility.UrlDecode(request.Value, System.Text.Encoding.GetEncoding(28591))
seem to have vanished (or are not yet there) in .NET Core RTM.
Our workaround is to create a separate util lib with the above encoding call that cannot target .NET Core.
Is there a way to configure request encoding in web.config or any other proper way of dealing with this?

Odata compression - Is there ANY support? (WCF Data Services 5.0 for WinRT)

Context:Currently using WCF Data Services 5.0 with Odata for a Windows 8 Store application.
Have been trying to compress the OData coming over the wire from my service today and running into plenty of issues surrounding support.
binary serialization isn't supported.
json isn't supported (library throws 'application/json' is currently not supported in Content-Type header)
json lite isn't released yet
adding gzip requests in the http response works (server returns compressed) - but client side lib doesn't seem to want to deserialize it. (xml parsing exceptions)
My final attempt today was to try and get a hold of the http response, and to manually deserialize the stream myself (GZipStream isn't available but i know there are 3rd party alternatives) - but I couldn't find ANY Microsoft.Data.Services.Client.WindowsStore events/overrides that would expose the stream to me.
I wanted to implement OData to leverage the performance and efficiency gains over standard WCF Web services - but with no way to compress the stream over the wire i don't get any.
Does anyone have any experience with this, or advice of how to approach?
Have you followed the same steps here to get json response.The client has to send MaxDataServiceVersion header:
http://blogs.msdn.com/b/astoriateam/archive/2012/04/11/what-happened-to-application-json-in-wcf-ds-5-0.aspx
I also checked that Odata 5.1.0 has been released on nuget. This has the better json support:
https://nuget.org/packages/Microsoft.Data.Services/5.1.0
Your other option is to use asp.net web api and try the odata support:
http://www.nuget.org/packages/Microsoft.AspNet.WebApi.OData

SOAP not getting encoded as MTOM in a WCF client

I am connecting to a DFS(Documentum Foundation Services) instance from a WCF client.
I am using basicHttpBinding and I have set the messageEncoding="Mtom". However, when I inspect the soap, I see the document within the SOAP envelop. The document part in the SOAP is about 1.33 times the actual doc size. So the message is getting Base64 encoded.
Do I have more settings to change on the WCF side Or is there a MTOM setting that is not enabled on the DFS side?
Does wsoma:OptimizedMimeSerialization have to be there in the WSDL?
Thanks
http://www.w3.org/Submission/WS-MTOMPolicy/
I guess, my question is: does the Java web service WSDL has to have this wsoma:OptimizedMimeSerialization element, otherwise it implies that the web service does not support MTOM?
Which also implies that if the Java based web service did support MTOM and then if I add a service reference using the WSDL, Visual Studio should automatically create the appropiate binding with messageEncoding="Mtom"??

How to upload a file to a WCF Service?

I've build a WCF Service to accept a file and write it to disk. The front-end consists of a page with SWFUpload which is handling the upload on the client side. Apparently, SWFUpload posts the data with a Content Type of: multipart/form-data.
I would think this ok but on the Service side I get an error. The error is "ProtocolException" expecting text/xml. I've tried different message encodings in the bindings but nothing seems to work.
How can I get this file uploaded using multipart/form-data?
#jdiaz,
#JasonS is right, to upload file you need to transfer it as a byte stream. You need to use WCF streaming. For example on how to upload file via WCF see an article from http://kjellsj.blogspot.com
What you want to use is probably MTOM, if you want it to be standard. Using this, you can have MIME multiparts messages.
You then have to read the file as a stream and stuff it into one of the parameters of the request.
It might be that your WCF service targets .NET Framework 3.5 and your IIS is running on .NET Framework 4.0. In this case (framework mismatch) you need to modify your service.
I believe you are going to have to tranfer the file as a byte array to WCF. You will need to handle the post from SWFUpload and convert to a byte array before sending to your service.