简体   繁体   中英

Changing WCF binding from wsHttp to netTcp

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?

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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