消耗WCF服务的.NET Core应用中的内容问题 [英] Content issue in .NET Core app Consuming a WCF service

查看:225
本文介绍了消耗WCF服务的.NET Core应用中的内容问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用新的Visual Studio WCF Connected服务从.NET Core Web API调用WCF服务方法。

I am trying to call a WCF service method from an .NET Core Web API using the new Visual Studio WCF Connected service.

但是在测试时,我收到以下错误:-

But when I am testing this, I get the following error:-


内容类型multipart / related; type = application / xop + xml; start = http://tempuri.org/0 ; boundary = uuid:9e7f9b02-4d9c-4ec1-bad4-1007704a579a + id = 1197;响应消息的start-info = text / xml与绑定的内容类型不匹配(text / xml; charset = utf-8)。如果使用自定义编码器,请确保正确实施IsContentTypeSupported方法。响应的前1024个字节为:'
--uuid:9e7f9b02-4d9c-4ec1-bad4-1007704a579a + id = 1197
Content-ID: http://tempuri.org/0
Content-Transfer-Encoding:8bit
内容类型:application / xop + xml; charset = utf-8; type = text / xml

The content type multipart/related; type="application/xop+xml"; start="http://tempuri.org/0"; boundary="uuid:9e7f9b02-4d9c-4ec1-bad4-1007704a579a+id=1197"; 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. The first 1024 bytes of the response were: ' --uuid:9e7f9b02-4d9c-4ec1-bad4-1007704a579a+id=1197 Content-ID: http://tempuri.org/0 Content-Transfer-Encoding: 8bit Content-Type: application/xop+xml;charset=utf-8;type="text/xml"

公开的WCF服务在传统的.NET Framework客户端应用程序中使用MTOM MessageEncoding ,我们可以在应用程序的配置文件中将客户端设置为使用MTOM,但在.NET Core中,我们没有可以在其中设置MessageEncoding的配置文件,所有这些配置
在当前代码中得到了照顾在Reference.cs(这是一个生成的文件)中。
我认为更改此生成的文件以设置MessageEncoding并不是一个好选择。

The exposed WCF service uses MTOM MessageEncoding and in traditional .NET framework client application, we can set the client to use MTOM in the application's config file but in .NET core, we don't have the config file where we can set the MessageEncoding and all this configuration is taken care of in the code present in Reference.cs(which is a generated file). I thinking changing this generated file to set the MessageEncoding is not a good option.

有什么想法可以解决此问题? p>

Any idea on what is the best way to handle this issue?

推荐答案

我刚从WCF Core团队得知,基于.NET Core的客户端当前不支持MTOM编码。这是一项要求的功能,它将在以后的版本中提供。
这是具有更多信息的github链接:在WCF运行时中添加MTOM支持

I just came to know from WCF Core team that currently MTOM encoding is not supported in .NET Core based clients. This is a requested feature which will be available in future versions. Here is github link which has more information: Adding MTOM support in WCF runtime

这篇关于消耗WCF服务的.NET Core应用中的内容问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆