1

我在代理中使用 ClientBase 通过服务接口调用我的 WCF 服务上的 REST:

public class CommunicationServiceProxy : ClientBase<ICommunicationService>, ICommunicationService

我还在每次调用之前添加了一个授权标头,以便我的服务将接受请求,如下所示:

private OperationContextScope AddHeader(OperationContextScope scope)

        {
            if (WebOperationContext.Current == null) return null;

            WebOperationContext.Current.OutgoingRequest.Headers.Add("Authorization", Header);

            return scope;
        }

一切正常,但现在,由于安全原因,我需要生成请求 URL 的签名(例如。http://myservice/contact/getstatus?id=1),问题是如何在使用上述代理类时获取此 URL,例如 WebOperationContext。 Current.OutgoingRequest 缺少此信息。

有人设法得到这个吗?我在这里有什么选择?

谢谢

4

1 回答 1

0

我找到的解决方案是使用 WCF 扩展,更具体地说是 IClientMessageInspector,那里有生成签名所需的所有信息。

于 2012-09-05T16:32:21.110 回答