0

I have a RESTful service which is exposed via WCF with the webHttpBinding.

I am now asked to get the TCP header (specifically the packet TTL). The difficult approach will be to switch to the net.tcp binding and handle all the HTTP layer by myself.

There must be an easier way... Please help!

Ronnyle
  • 147
  • 9

1 Answers1

0

As you've found out, WCF abstracts the message transport (TCP, HTTP, ...) by implementing the binding concept (netTcpBinding, basicHttpBinding, ...). The benefit is to be able to easily (most of the time) change bindings without affecting the service code. The trade off for this ease is hiding the transport details from service code. In fact, its fairly difficult to get the client IP address in WCF.

On the other hand, WCF is so extensible that you can "re-implement" the webHttpBinding as a custom binding so you can bubble up the TCP info you want. This SO question & answer will give you a start on a custom binding but you'll likely need to create a custom HTTP transport component to access the TCP details. When a tool makes you work this hard, there's a good chance you're using the wrong tool. Just sayin' ... :)

Community
  • 1
  • 1
Sixto Saez
  • 12,610
  • 5
  • 43
  • 51