Two Bindings for the same contract
-
09-10-2019 - |
Question
I have a contract for which i have an basicHttpBinding.
<endpoint address="http://localhost:49654/BookShopService.svc" binding="basicHttpBinding" contract="BookShop.IBookShopService">
</endpoint>
I want to add another endpoint with wsHttpBinding, for the same binding. What are the steps I have to take? What would be the resulting address?
Solution
Just add another endpoint with a different address, it should look like this:
<endpoint address="http://localhost:49654/BookShopService.svc" binding="basicHttpBinding" contract="BookShop.IBookShopService">
</endpoint>
<endpoint address="http://localhost:49654/BookShopServiceWS" binding="wsHttpBinding" contract="BookShop.IBookShopService">
</endpoint>
There is a primer on MSDN.
OTHER TIPS
If you are running in IIS, then you shouldn't supply a fully qualified address - the address will be determined by IIS and so supply one can cause deployment problems. So, using Greg Sansom's answer as a foundation, I'd suggest
<endpoint address=""
binding="basicHttpBinding"
contract="BookShop.IBookShopService" />
<endpoint address="ws"
binding="wsHttpBinding"
contract="BookShop.IBookShopService" />
where ws
is a relative addresses to the service location.
e.g.
- http://localhost:49654/BookShopService.svc - the basicHttp endpoint
- http://localhost:49654/BookShopService.svc/ws - the wsHttp endpoint
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow