tags:

views:

107

answers:

4

When specifying an address as part of an endpoint, the format is:

http://localhost:8080/MyWCFService or net.tcp://localhost:8080/MyWCFService

The guidance (in books, MSDN etc) states the '/MyWCFService' is a 'path' to the service.

What exactly does this mean?

Is it the Type of the service implementation (as opposed to say a physical directory path, a virtual root path, a namespace etc etc)?

Whatever it actually is, how does the CLR/WCF library utilise that data to do its work e.g. if its a type, I can see that the servicehost (serviceHost.Open();) would be able to instantitate the relevant object and invoke the requested method.

A: 

/MyWCFService is the virtual directory in ASP.NET. You'd probably have something like /MyWCFService/SomeService.svc in your solution or project.

Jarrett Meyer
A: 

In your example, MyWCFService is not a physical address, it corresponds to the EndPoint that is configured for a particular binding.

One ServiceHost can host multiple sevices and each have multiple endPoints.

If your service is hosted by IIS, then the base address would be a virtual path to the .svc file.

ichiban
A: 

The address tells you where your service is. It provides the location of the service as well as the transport protocol for communication with the service.

The localhost portion is for the target machine while the '/MyWCFService' portion is an optional specific path.

transmogrify
+1  A: 

The address is just a string describing a "location" where a service exposes his services, or a client connects to. By default, it has no direct connection to anything "physical", e.g. it doesn't refer to a file or anything.

In case of hosting your service in IIS, then the first part of your address right after the machine and port are in fact the name of the IIS virtual directory where your *.svc file is located.

In case of MSMQ, your service address must correspond to the MSMQ queue name (or vice-versa).

Other than those cases - the address is really just a way to describe where to find a particular service.

The first part http://, https://, net.tcp:// and so on is usually called the "schema" and refers loosely to the transport protocol used to connect your client to the service.

The second part is typically a machine name, optionally with port number. This part is connected to a physical entity, of course - your machine must exist, the port number must be available and useable.

But the third part, what you called the "path" to the service, can really be anything you want it to be, if you're hosting your service yourself (e.g. in a console app or a Windows NT Service). If you're self-hosting, the path has absolutely no relation to any physical path on disk, virtual directory or otherwise.

The service host - the piece of code that will actually host and run your service class, which is just a regular .NET class - will expose / publish any number of endpoints with address, binding and contract. The service host therefore defines what URI's are valid for its services. The client(s) then need to connect to one of those published endpoints by specifying the same address - schema (http://, https://, net.tcp://), machine name and optionally port, and the path of the service.

Marc

marc_s