I know this is a FAQ, and I’ve read all similar Q’s and A’s but I’m still not coming right.
I’m a newbie at web services and ASP.NET in general. I have a small WCF service application written by a colleague which worked and was demo’ed on his pc. On my pc, and with no changes, I can’t get it to be accepted by the WCF Test Client program when adding it as a service (error message below). My colleague is now on leave!
The project properties are set to start WcfTestClient.exe using the VS development server with an auto-assigned port number. The project has a webform.aspx and a Global.asax file added which are needed for the service.
I have run
netsh http add urlacl url=http://localhost:51568/Service1.svc user=<loginname>
My questions are how do I get the service started by WcfTestClient, and the webform on the browser?
I have looked at various SO answers to similar questions but am still stumped.
Failed to add a service. Service metadata may not be accessible. Make
sure your service is running and exposing metadata. Error: Cannot
obtain Metadata fromhttp://localhost:51568/Service1.svcIf this is a
Windows (R) Communication Foundation service to which you have access,
please check that you have enabled metadata publishing at the
specified address. For help enabling metadata publishing, please
refer to … Error URI:http://localhost:51568/Service1.svc
Metadata contains a reference that cannot be resolved:
‘http://localhost:51568/Service1.svc‘. There was no endpoint
listening athttp://localhost:51568/Service1.svcthat could accept the
message. This is often caused by an incorrect address or SOAP action.
See InnerException, if present, for more details. Unable to connect
to the remote server No connection could be made because the target
machine actively refused it 127.0.0.1:51568HTTP GET Error URI:
http://localhost:51568/Service1.svcThere was an error downloading
‘http://localhost:51568/Service1.svc‘. Unable to connect to the
remote server No connection could be made because the target
machine actively refused it 127.0.0.1:51568
This is my web.config:
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service name="Service1" behaviorConfiguration="DefaultBehavior">
<endpoint address="http://localhost:*/Service1" binding="basicHttpBinding" contract="IService1" />
<endpoint address="http://localhost:*/Service1/mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="DefaultBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
Something strange to me regarding port numbers is that if I don’t set the project to start with the external program then the browser lists the directory listing at localhost port 50345 which is a different port number to 51568.
And
This simply means your WCF service is hosted at the latter port. You can change this on the ‘Web’ tab in your project’s properties.