简体   繁体   English

将WCF绑定从wsHttp更改为netTcp

[英]Changing WCF binding from wsHttp to netTcp

I have problems with a WCF Service WsHttpBinding that I want to change to a NetTcpBinding. 我想将WCF服务WsHttpBinding更改为NetTcpBinding。 Previously, I have set up the Service in my IIS7 local machine and it works with the WsHttpBinding. 以前,我已经在IIS7本地计算机上设置了Service,并且可以与WsHttpBinding一起使用。

The Proxy for this Service has a CustomBehavior which adds two message headers before sending the request message 此服务的代理具有一个CustomBehavior,它在发送请求消息之前添加了两个消息头

When I change the binding to a NetTcpBinding I get the following Exception in my logs.. 当我将绑定更改为NetTcpBinding时,我的日志中出现以下异常。

 Exception: System.ServiceModel.ServiceActivationException: Service /ConsignmentService/Consignment.svc cannot be activated due to an exception during compilation. The exception message is: Exception has been thrown by the target of an invocation ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ServiceModel.MessageHeaderException: There is not a header with the name "ClientID" og namespace 'http://AmphoraExtension/Header' in the message.
   ved System.ServiceModel.Channels.MessageHeaders.GetHeader[T](String name, String ns, XmlObjectSerializer serializer)
   ved System.ServiceModel.Channels.MessageHeaders.GetHeader[T](String name, String ns)

This works fine with the wsHttpBinding, but when switching to NetTcpBinding it doesn't. wsHttpBinding可以正常工作,但是切换到NetTcpBinding时不能。 What am I missing here? 我在这里想念什么?

Not too sure about the CustomBehaviour, but I've just been through exactly the same issue getting a WCF service running on IIS under netTcp. 对于CustomBehaviour不太清楚,但是我遇到了完全相同的问题,即在netTcp下在IIS上运行WCF服务。 Check out my question here: 在这里查看我的问题:

WCF netTcpBinding hosted on IIS7.5 Stops Working IIS7.5上托管的WCF netTcpBinding停止工作

After much fiddling about I ended up answering my own question, and have posted a checklist for getting a netTcp service running on IIS. 经过一番摆弄之后,我最终回答了我自己的问题,并发布了一份清单,以使IIS上运行netTcp服务。

Solved it myself. 我自己解决了。

This was my bad. 这是我的坏事。 A request was made to the WCF server BEFORE the actual request with parameters and Header, which forced the Service class to be instantiated. 在带有参数和标头的实际请求之前,已向WCF服务器发出了一个请求,这迫使实例化Service类。 And in the constructor there was logic around the header data that was supposed to be there. 在构造函数中,应该在标头数据周围存在逻辑。 I made a workaround for this 我为此做了一个解决方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM