Reputation: 458
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
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 :-
Upvotes: 2
Views: 1438
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