Usually when i implement a 3rd party WCF web service then i get a URL that ends with an .svc
extension.
I just created a WCF Web Service in VS2010 and i'm able to run that service, but i don't see any URL in the Test Client that ends with a .svc
extension.
Is there something else i need to do in order to get such a URL? Because usually from there people are able to get the WSDL also by adding ?wsdl
to the end like:
http://site.com/service1.svc?wsdl
How can i generate such a URL in my Web Service?
This is what i have in my App.Config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="TestWebservice.Test">
<endpoint address="" binding="wsHttpBinding" contract="TestWebservice.ITest">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8732/Design_Time_Addresses/TestWebservice/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="True"/>
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
I removed the mexHttpBinding
endpoint from my configuration file. When i launch my Web Service now it automatically shows a URL to a WSDL:
http://localhost:8732/Design_Time_Addresses/TestWebservice/?wsdl
The /
before the ?wsdl
part seems to be very important. Otherwise it won't work.
But that still leads me to my last question. How can i specify the URL to the .svc
file? I'd like to have a URL like: http://localhost:8732/Design_Time_Addresses/TestWebservice/Test.svc?wsdl
I got a bit further. I read this: http://msdn.microsoft.com/en-us/library/aa751792.aspx
So i created a Test.svc
file in the root of my project with the following code:
<% @ServiceHost Service="TestWebservice.ITest" %>
Then i tried to access my svc
file through the following URLs, but both didn't work for me:
http://localhost:8732/Design_Time_Addresses/TestWebservice/Test.svc
http://localhost:8732/Design_Time_Addresses/Test.svc
Is it even possible to host a svc
inside Visual Studio? Or do i really need to host it in IIS first?
I finally have it working! I re-added the mexHttpBinding
to my App.Config.
I installed IIS7. Published the Web Service to a folder in my C:\
drive. Then mapped that folder in IIS and tried to request the .svc
file in the browser.
At first it didn't work for me because it didn't recognize the .svc
extension. Then all i had to do was enter the following cmd: aspnet_regiis.exe -i
and now everything works fine.
Everything seems to be working fine now. Guess you can't request a .svc
file when the service is hosted by Visual Studio. But it works when its hosted in IIS.