Nitin Bourai
Nitin Bourai

Reputation: 458

Endpoint Address when Hosting in Window Service vs IIS

i have a Service with a Name MyService and It implements a Service Contract IMyService

when i am hosting in IIS i have added a SVC file and a Web.config and provided the base address as

http://localhost:49495/MyService.svc/

Its working fine

Now i want to Host the same Service in a Windows Service and now i am confused what should i give in base address of App config of a Windows Service

should i give Class name MyWindowService Which Implement ServiceHost

like this base address :-

http://localhost:49496/MyWindowService/

Upvotes: 2

Views: 1438

Answers (1)

kmp
kmp

Reputation: 10905

The base address can be anything. As you are hosting it as an HTTP endpoint I would just make it exactly the same as your web version. The important bit of the configuration is as follows:

<service name="MyService"> <host> <baseAddresses> <add baseAddress="http://localhost:49495/MyService.svc"/> </baseAddresses> </host> <endpoint address="" binding="wsHttpBinding" bindingConfiguration="WsHttpBinding" contract="IMyService" /> </service>

the name is the concrete class implementation of the service contract and the contract is the interface (so MyService and IMyService in your example).

he rest is up to you - I personally don't think the client needs to care whether the service is hosted in a windows service or IIS so I would have the endpoint with the .svc so I can freely swap it around. As long as the URL stays the same and the binding configuration also you can host it how you like.

Upvotes: 1

Related Questions