7

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>

Edit

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


Edit 2

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?


Edit 3 - Fixed!

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.

Vivendi
  • 20,047
  • 25
  • 121
  • 196
  • Please post your service's config file - chances are if you're using .NET 4.0 and didn't state an address for your service, it's using fileless activation (assuming its hosted in IIS). – Tim Mar 28 '13 at 07:47
  • @Tim Added my App.Config – Vivendi Mar 28 '13 at 07:53
  • No .svc file specified. Have you tried simply appending `?wsdl` to the address in the WCF Test Client? – Tim Mar 28 '13 at 07:55
  • @Tim Just tried it. The Test Client gives me this URL (i added the `wsdl` to it): `http://localhost:8732/Design_Time_Addresses/TestWebservice/mex?wsdl`. But that gives me a blank page. I also have no idea how to specify a `.svc` file. This is my first WCF service. Could you perhaps point me in the right direction? I'm not sure what to do. – Vivendi Mar 28 '13 at 07:59
  • Try `http://localhost:8732/Design_Time_Addresses/TestWebservice?wsdl` - note that I removed `/mex` from the URL. Is this hosted in IIS or self-hosted? You mentioned App.config, so I'm thinking the latter. – Tim Mar 28 '13 at 08:01
  • @Tim Same thing, blank page. It's self-hosted from within VS2010. - Just noticed that IE says ***Page not found (error 400)***. FireFox simply displays a blank page. – Vivendi Mar 28 '13 at 08:03
  • Hmm....not sure. I have to go for now (sorry), but I'll try to look at it tomorrow if someone else doesn't answer first. – Tim Mar 28 '13 at 08:07
  • 3
    Glad you got it working. You should post your solution as an answer for future users (you can also accept it as the answer). – Tim Mar 28 '13 at 18:37
  • Could you please post your solution? – Serge Nov 08 '13 at 14:00
  • It is not required, its optinal. – Omer Faruk Zorlu Aug 04 '14 at 20:33

0 Answers0