so i'm a litle confused over what the service endpoints and host base address is for. In all the examples i have walked through so far they talk about setting up the endpoints with the required bindings and you can normally navigate to those endpoints
Hoever when i use the following config to set up and host my service it only seems to expose the Hosts base address.
<configuration> <system.web> <compilation debug="true" /> </system.web> <!-- When deploying the service library project, the content of the config file must be added to the host's app.config file. System.Configuration does not support config files for libraries. --> <system.serviceModel> <services> <service name="HostService.EvalService"> <endpoint address="http://localhost:8080/basic" binding="basicHttpBinding" contract="HostService.IEvalService" /> <endpoint address="http://localhost:8080/ws" binding="wsHttpBinding" contract="HostService.IEvalService" /> <endpoint address="mex" binding="mexHttpBinding" name="mex" contract="IMetadataExchange" /> <host> <baseAddresses> <add baseAddress="http://localhost:8080/EvalsService" /> </baseAddresses> </host> </service> </services> <behaviors> <serviceBehaviors> <behavior name=""> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel> </configuration>
Can someone explain this to me?
The endpoint address is represented in the Windows Communication Foundation (WCF) programming model by the EndpointAddress class, which contains an optional Identity property that enables the authentication of the endpoint by other endpoints that exchange messages with it, and a set of optional Headers properties, ...
The service configuration has been modified to define two endpoints that support the ICalculator contract, but each at a different address using a different binding.
Sometimes in our mind the question arise; can we implement multiple service contract in WCF service? And the answer is, Yes we can. Service class implement multiple service interfaces, and then expose each service using a different endpoint.
Default EndpointsIf the service host does not define any endpoints (neither in config nor programmatically) but does provide at least one base address, WCF will by default add endpoints to the service. These are called the default endpoints.
When you host the WCF service on IIS, the base address can only be the URL to the .svc file. If you specify any other base address, it's ignored. You can still specify the relative URI for your endpoints, such as address="basic"
or address = "ws"
. Then the address on the endpoint becomes <URL to the .svc file>/basic
and <URL to the .svc file>/ws
in this case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With