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

查看:33
本文介绍了使用 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;类型=应用程序/xop+xml";start="http://tempuri.org/0";边界="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内容 ID:http://tempuri.org/0内容传输编码: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 服务使用 MTOM MessageEncoding,在传统的 .NET 框架客户端应用程序中,我们可以在应用程序的配置文件中设置客户端使用 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.

您知道处理此问题的最佳方法是什么吗?

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天全站免登陆