Reputation: 1536
I have problems with a WCF Service WsHttpBinding that I want to change to a NetTcpBinding. Previously, I have set up the Service in my IIS7 local machine and it works with the WsHttpBinding.
The Proxy for this Service has a CustomBehavior which adds two message headers before sending the request message
When I change the binding to a NetTcpBinding I get the following Exception in my logs..
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. What am I missing here?
Upvotes: 1
Views: 986
Reputation: 1536
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. And in the constructor there was logic around the header data that was supposed to be there. I made a workaround for this
Upvotes: 0
Reputation: 5209
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. Check out my question here:
WCF netTcpBinding hosted on IIS7.5 Stops Working
After much fiddling about I ended up answering my own question, and have posted a checklist for getting a netTcp service running on IIS.
Upvotes: 1