简体   繁体   English

我可以在 .Net Core Web Api 项目的 .Net Dll 中使用 mtom 调用 Web 服务吗?

[英]Can I call a web service using mtom in a .Net Dll from a .Net Core Web Api project?

I know message encoding with mtom from 'BasicHttpBinding' isn't possible in .Net Core.我知道在 .Net Core 中不可能使用来自“BasicHttpBinding”的 mtom 进行消息编码。 And I need to call a web service, using it, to send documents to a client.我需要调用一个 Web 服务,使用它向客户端发送文档。 Can I put the web service call into .Net Dll and then call it from my .Net Core app API?我可以将 Web 服务调用放入 .Net Dll 中,然后从我的 .Net Core 应用程序 API 中调用它吗?

I read that I can, if the call is to a .Net Standard Dll, but not a .Net Framework Dll?我读到我可以,如果调用的是 .Net Standard Dll,而不是 .Net Framework Dll? Which would this be and is it possible?这会是哪一种,这可能吗?

var binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport)
{ 
    // MessageEncoding = WSMessageEncoding.Mtom, not supported in .Net Core
    TransferMode = TransferMode.Streamed
};

EndpointAddress endpoint = new EndpointAddress(url);
var channelFactory = new ChannelFactory<T>(binding, endpoint);
var webService = channelFactory.CreateChannel();

I'm a little confused here as to what I can and can't do.对于我能做什么和不能做什么,我在这里有点困惑。

Regarding your question the DLL needs to be .NET Standard, again the MTOM is not supported.关于您的问题,DLL 需要是 .NET Standard,同样不支持 MTOM。

You may use the following .NET Core MTOM Encoder by Lenny Kean.您可以使用 Lenny Kean 的以下.NET Core MTOM 编码器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM