【问题标题】:WCF adding additional HTTP header to HTTP response for transporting SOAP messageWCF 向 HTTP 响应添加额外的 HTTP 标头以传输 SOAP 消息
【发布时间】:2014-07-15 11:50:02
【问题描述】:

我正在使用带有 SOAP 消息架构的 WCF。我的服务使用 BasicHttpBinding 来传输我的 SOAP 消息。我需要向 HTTP 响应添加 2 个不同的 HTTP 标头(源和缓存控制)。我知道如果启用 aspNetCompatibilityEnabled,我可以在 Global.asax 文件中执行此操作,但是有一个问题 - 我正在使用 Windows 服务来托管我的 WCF。 aspNetCompatibilityEnabled 仅在 IIS 下工作。任何人都可以帮助我的方法吗?

【问题讨论】:

    标签: c# web-services wcf soap


    【解决方案1】:

    我相信这篇文章是关于你想做的事情:here。你可以这样做:

    var context = WebOperationContext.Current;
    HttpResponseHeader cacheHeader = HttpResponseHeader.CacheControl;
    String cacheControlValue = String.Format("max-age={0}, must-revalidate", maxCacheAge);
    context.OutgoingResponse.Headers.Add(cacheHeader, cacheControlValue);
    

    【讨论】:

    • 是的,但在这种情况下,我需要在每个网络方法中添加这样的签名。也许为此目的有一些集中的地方。顺便说一句!
    • 所以也许消息检查器可以施展魔法:link 看起来很有希望,但我从来没有使用过这些。
    猜你喜欢
    • 1970-01-01
    • 2017-12-27
    • 2017-02-24
    • 2016-03-25
    • 1970-01-01
    • 2017-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多