WCF 自定义标头未出现在服务中
我想知道是否有人遇到过这个问题并有答案或指示。我实现了 IClientMessageInspector 以将标头添加到客户端上的肥皂消息中。因此,在 BeforeSendREquest 中我调用 MessageHeader.CreateHeader。这似乎有效,因为我在 Fiddler 中看到消息,其中的标题位于集合中。在服务方面,我有一个自定义的身份验证管理器。当服务调用进入实现时,我看不到插入的标头。我有一种感觉,ServiceModel 堆栈在反序列化期间会跳过我的标头,但不确定。另外,不确定如何解决这个问题(如果确实发生了这种情况)。也许在服务端实现 IClientMessageInspector 的等效项?
任何想法/指针都会有帮助。
I was wondering if somebody came across this issue and has an answer or pointer. I implemented IClientMessageInspector to add a header to my soap message on the client. So, inside BeforeSendREquest I call MessageHeader.CreateHeader. This seems to work because i see the message in Fiddler with the header in the collection. On the service side, i have a custom authenticationManager. When the service call enters the implementation I dont see the header i inserted. I have a feeling the ServiceModel stack is skipping my header during deserialization but not sure. Also, not sure on how to fix this if its truly what is happening. Maybe implement the equivalent of IClientMessageInspector on the service side?
Any idea/pointers would be helpful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在服务器端 WCF 代码中,为了对来自客户端的 SOAP 标头(由 IClientMessageInspector 插入)进行操作,我使用了 IDispatchMessageInspector 的实现。在其 AfterReceiveRequest() 方法中,我使用 request.Headers.FindHeader() 来查看是否存在预期的标头。
In server-side WCF code, to act upon a SOAP header from the client (inserted by IClientMessageInspector), I have used an implementation of IDispatchMessageInspector. In its AfterReceiveRequest() method, I use request.Headers.FindHeader() to see if the expected header is present.