IsOneWay WCF REST服务上的WebOperationContext.Current.IncomingRequest.Headers为空 [英] WebOperationContext.Current.IncomingRequest.Headers Empty on an IsOneWay WCF REST service

查看:73
本文介绍了IsOneWay WCF REST服务上的WebOperationContext.Current.IncomingRequest.Headers为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I'm experiencing an unexpected behavior within a WCF REST service that is marked as IsOneWay.

我正在将参数添加到客户端的请求标头中,在服务器端,我试图通过 WebOperationContext.Current.IncomingRequest.Headers  为空.

I am adding params to the request headers from the client, on the server side I'm trying to access these via WebOperationContext.Current.IncomingRequest.Headers. On a standard service method, the Headers collection is filled and has the headers that I have set. When I change the method to IsOneWay however, WebOperationContext.Current.IncomingRequest.Headers is empty.

// Works
[WebInvoke(UriTemplate = "MyMethod/{id}")]
public void MyMethod(string id, object data)
{
   
WebOperationContext.Current.IncomingRequest.Headers.Count; // > 1
}

// Fails
[WebInvoke(UriTemplate = "MyMethod/{id}")]
[OperationContract(IsOneWay = true)] // <-- This is the issue
public void MyMethod(string id, object data)
{
   
WebOperationContext.Current.IncomingRequest.Headers.Count; // 0
}

Any idea how I can still access the headers with IsOneWay set?

推荐答案

客户端发送的标头是?与提琴手确认.
are the headers sent by the client? check with fiddler.


这篇关于IsOneWay WCF REST服务上的WebOperationContext.Current.IncomingRequest.Headers为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆