c# - OperationContext.Current 在 .net 核心中为空
问题描述
我通过SoapCore在我的 .net 核心项目中提供 WCF 服务。在其中一种方法中,我想访问 SOAP 信封头信息。为了测试这一点,我添加了以下代码:
[ServiceContract]
public interface IDataService {
[OperationContract]
string TransmitObject(XElement node);
}
// -------------------------------------------------------------------------
public string TransmitObject(XElement node) {
foreach(var header in OperationContext.Current.IncomingMessageHeaders) {
Console.WriteLine(header.ToString());
}
return JsonConvert.SerializeXNode(node, Formatting.None);
}
但是,在这种情况下, OperationContext.Current 属性始终为null
。为了使这项工作有效,我需要进行哪些更改?
解决方案
推荐阅读
- bash - Bash:查找特定文件并从名称中删除最后 5 个字符
- c++ - c ++:错误:获取临时地址[-fpermissive]
- javascript - 在 HTML 网页中通过 Javascript 列出存储在 Google Drive 中的文件
- asp.net-mvc - 区域 MVC 中 API 的路由
- excel - 如何在excel中的单个堆叠水平条形图上绘制一系列起点和终点
- c++ - 如何实现线程列表
- reactjs - Mobx 和反应。不支持实验语法
- angular - 等效于 Angular 中 C# 的简单“for”(使用索引迭代)
- python - 在嵌套列表python中查找所有可能的插入组合
- jquery - Ajax 成功刷新(如阴影)中的 Bootstrap 模态弹出窗口比消失 MVC