Wednesday, 4 January 2012

WCF Absolute Vs Relative address

After long break, i started working on WCF services and i struck with a problem when i hosted my service in IIS. I figured out that i have given an absolute end point address, which is wrong. So i figured out below in MSDN

'When hosting with IIS, you do not manage the ServiceHost instance yourself. The base address is always the address specified in the .svc file for the service when hosting in IIS. So you must use relative endpoint addresses for IIS-hosted service endpoints. Supplying a fully-qualified endpoint address can lead to errors in the deployment of the service. For more information, see Deploying an Internet Information Services-Hosted WCF Service."

So with following config
       
<services>
   <service name="RestService.SimpleService">
        <endpoint address="/Sample" binding="webHttpBinding"
                  contract="RestService.SimpleInterface" behaviorConfiguration="webby"
                   bindingConfiguration="secure"/>
     </service>
</services>

i hosted my WCF(REST) as 'SimpleRestService' application, so i need to use http://localhost/SimpleRestService/yoursvcfilename.svc/Sample/youroperationname

No comments: