Reputation: 1683
I Created the WCF Service Library in MS Web Developer 2010 Express with ITestSerivce being the Service Contract and gaving following Web.config configuration. But im getting this error : Error: Cannot obtain Metadata from http://localhost:56016/TestService.svc : I dont understand why the url is http://localhost:56016 where in base address is http://localhost:8001
Can anybody help me with this issue.
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<services>
<service behaviorConfiguration="ServiceBehavior" name="TestService">
<host>
<baseAddresses>
<add baseAddress ="http://localhost:8001/" />
</baseAddresses>
</host>
<endpoint address="" binding="wsHttpBinding" contract="ITestService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<!--Setting httpGetEnabled you can publish the metadata -->
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="SampleServiceBinding">
<security/>
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
</configuration>
Upvotes: 0
Views: 314
Reputation: 107247
The <baseAddresses>
configuration is only for self-hosted services + applications, and is not used by IIS / WAS.
Where you 'put' the .svc on your web server / site defines its url, unless you are using a feature such as file-less activation (article here)
Your IIS url will be something like
http://localhost:8001/MyApp/TestService.svc?wsdl
I'm not sure why WCF test client is defaulting to the wrong URL - just type in the correct one and it will cache it.
Upvotes: 0
Reputation: 7876
There are a few problems with the config above.
The service element has the name attibute which is not fully qualified name.
The endpoint element has the contract attribute value which is not fully qualified name.
A fully qualified name is as shown below:
MyWCFService.TestService (i.e. namespace.ServiceName)
If you are running the same on Cassini web server then right click on properties and under the web tab make sure that the "User Visual Studio Development Server" option is selected and the "Auto-assign Port" option is not selected. Rather select "Specific Port" and use 8001 to match your configuration
Upvotes: 2