如何在自定义 WCF HTTP 绑定中存储标头信息

发布于 2024-07-30 05:51:42 字数 456 浏览 1 评论 0原文

基本上,我想从与侦听套接字不同的源获取 HTTP 请求。 但是,由于提供的绑定不提供对此的支持,因此我目前正在构建自己的绑定。

我当前的绑定由 WebMessageEncoder 和自定义 TransportBindingElement 组成,它引用自定义 ChannelListener,该 ChannelListener 使用实现 IReplyChannel 接口的自定义通道。 ServiceModel 调用“receiveRequest”方法,该方法随后应返回 RequestContext。

但是,RequestContext 类仅包含一个 RequestMessage 属性,我应该将其放入 Message 对象中。 截至目前,我不确定将与 WebGet / WebInvoke 属性中的 UriTemplates 匹配所需的所有 HTTP 标头放在哪里。

你能帮我解决这个问题吗? :)

问候

Basically, I want to get HTTP requests from a different source than a listening socket. However, since the provided bindings don't offer support for this, I am currently building my own binding.

My current binding consists of the WebMessageEncoder and of a custom TransportBindingElement, which references a custom ChannelListener which uses a custom channel which implements the IReplyChannel interface. The ServiceModel invokes the "receiveRequest" method, which should afterwards return a RequestContext.

However, the RequestContext class only contains a RequestMessage property where I should put in the Message object. As of this fact, I'm not sure where to put all the HTTP headers which are needed to match on UriTemplates in WebGet / WebInvoke attributes.

Could you please help me with this one? :)

Greetings

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

江南月 2024-08-06 05:51:42

据我所知,WebHttp 调度程序关注两件事:

  • HttpRequestMessageProperty,您应该创建它并将其存储在传输通道生成的请求消息的 Properties 集合中。
  • 与请求关联的 URL,您希望确保在将消息传递到通道堆栈之前填充传输通道(这应该保存在 msg.Headers.To 中)。

The WebHttp dispatcher looks at two things, from what I remember:

  • The HttpRequestMessageProperty, which you should create and store in the Properties collection of the request message produced by your transport channel.
  • The URL associated with the request, which you want to make sure your transport channel fills in before passing the message down the channel stack (this should be saved in msg.Headers.To).
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文