Reputation: 4107
I have a WCF service and I am able to create proxies for it if the project in which I am creating the proxies (by adding a service reference) is in the same solution as the WCF service.
However, if I try to add a service reference in a project, which is in a different solution to the WCF service (which I do have running), it is unable to find the endpoint.
The are message talks about meta data, but I have added the following behaviour which exposes the metadata
<serviceMetadata httpGetEnabled="true" />
The details of the error message are:
There was an error downloading 'http://localhost:8112/LTA/_vti_bin/ListData.svc/$metadata'.
The request failed with HTTP status 405: Method Not Allowed.
Metadata contains a reference that cannot be resolved: 'http://localhost:8112/LTA'.
There was no endpoint listening at http://localhost:8112/LTA that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
The remote server returned an error: (404) Not Found.
If the service is defined in the current solution, try building the solution and adding the service reference again.
Does anyone have any idea what the problem is? The whole ServiceModel element is:
<system.serviceModel>
<services>
<service name="WCFLicenceService.LicenceTrackerService">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8112" />
</baseAddresses>
</host>
<endpoint address="LTS" binding="basicHttpBinding" contract="WCFLicenceService.ILicenceTrackerService" />
<endpoint
address="net.tcp://localhost:8113/LTS"
binding ="netTcpBinding"
contract="WCFLicenceService.ILicenceTrackerService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
<readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647" />
</binding>
</basicHttpBinding>
<netTcpBinding>
<binding maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
<readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647"/>
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>
Upvotes: 1
Views: 1429
Reputation: 2802
As you had seen, the service reference is created against http://localhost:8112/LTA/_vti_bin/ListData.svc/$metadata
which has to be live. If the Web service project is in the same Sln, VS IDE could do the trick for you through launching the service on built-in Web server like IIS Express. If the service project is sitting in another sln, you will have to run the service in another instance of VS IDE.
For large projects, and for those Web services to be consumed by many other projects siting in other VS solutions, it is better not to use the Service Reference approach, rather, you may create a client API for each service. And the client API could be distributed to other .NET projects. For more details about how to create client API and respective benefits, please check WCF for the Real World, Not Hello World
Upvotes: 2