I created a WCF web service and created a new site in IIS (7). I created a new port (8002) for http requests. I can browse to the site and get the typical “You do not have permission to view this directory …” so I know the site is working. However, I set my endpoint address to “http://1.1.1.1:8002” in my web.config (where 1.1.1.1 is replaced with my actual real IP address). when I browse to the service with http://1.1.1.1:8002/service.svc I get page cannot be found error. There is a service.svc in the root folder of the site. What is wrong with the setup?
Here is the web.config file if helpful (again, the 1.1.1.1 is replaced with my real IP address):
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<customErrors mode="Off"/>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicBinding">
<security mode="None">
<transport clientCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="WcfService.ServiceBehavior" name="WcfService.Service">
<endpoint address="http://1.1.1.1:8002" binding="basicHttpBinding" bindingConfiguration="BasicBinding" contract="WcfService.IService">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="WcfService.ServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
You cannot control the address of your service in configuration file when hosting in IIS. You can control only relative address of the endpoint – it is relative to .svc file.
So if you host the service in the site http://YourIP:8002 its address is http://YourIP:8002/Service.svc and the address element in the endpoint is relative to this address. But I expect you don’t host the service directly in the site. You have some application in the site and the name of the application is part of the URL: http://YourIP:8002/YourApplicationName/Service.svc Actually every folder used to nest the service is part of the URL.