消耗WCF服务的.NET Core应用中的内容问题

编程入门 行业动态 更新时间:2024-10-24 14:25:49
本文介绍了消耗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 = tempuri/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: tempuri/0 Content-Transfer-Encoding:8bit 内容类型:application / xop + xml; charset = utf-8; type = text / xml

The content type multipart/related; type="application/xop+xml"; start="tempuri/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: tempuri/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应用中的内容问题

本文发布于:2023-11-03 14:51:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1555405.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:消耗   内容   NET   WCF   Core

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!