3

I'm creating a WCF4 service with REST and SOAP endpoints to be hosted in IIS 7.5. I have used the WCF4 REST template as an example. However I have a few questions regarding my setup so far.

Here's my webconfig

<system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
    <behaviors>
        <endpointBehaviors>
            <behavior name="REST">
                <webHttp helpEnabled="true"/>
            </behavior>
        </endpointBehaviors>
        <serviceBehaviors>
            <behavior name="MEXGET">
                <serviceMetadata httpGetEnabled="true"/>
                <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <services>
        <service behaviorConfiguration="MEXGET" name="Project.WebService.VehicleService">
            <endpoint 
                address="" 
                behaviorConfiguration="REST" 
                binding="webHttpBinding" 
                contract="Project.WebService.IVehicleService" />
            <endpoint 
                address="soap" 
                binding="basicHttpBinding" 
                contract="Project.WebService.IVehicleService" />
            <endpoint 
                address="mex" 
                binding="mexHttpBinding" 
                contract="IMetadataExchange" />
        </service>
    </services>
</system.serviceModel>

I have removed the standardEndpoints section and added endpoints of my own. There are no .svc files as I've set the routes in the global.asax as shown below

private void RegisterRoutes()
{
    RouteTable.Routes.Add(new ServiceRoute("VehicleService", new WebServiceHostFactory(), typeof(VehicleService)));
}

The help pages can be accessed via http://localhost:1313/ServiceTest/VehicleService/help

I've also used the WCF Test Client to access http://localhost:1313/ServiceTest/VehicleService/mex which shows the metadata for the SOAP endpoint

But how do I retrieve the WSDL of the service?

With an svc file I can find the wsdl at http://localhost:1313/ServiceTest/VehicleService.svc?wsdl However I do not have a .svc file. And neither can I find the WSDL at http://localhost:1313/ServiceTest/VehicleService?wsdl or http://localhost:1313/ServiceTest/VehicleService/soap?wsdl

Do I need to add a .svc file if I want to publish WSDL for the SOAP endpoint?

Freek
  • 179
  • 1
  • 5
  • 13

2 Answers2

6

I have managed to get the WSDL working at http://localhost:1313/ServiceTest/VehicleService?wsdl. The solution was using new ServiceHostFactory instead of new WebServiceHostFactory in the global.asax. With WebServiceHostFactory you lose the WSDL functionality.

A similar question can be found here: ServiceRoute + WebServiceHostFactory kills WSDL generation? How to create extensionless WCF service with ?wsdl

Community
  • 1
  • 1
Freek
  • 179
  • 1
  • 5
  • 13
0

You should be able to get the WSDL by using the mex URL directly from the browser:

http://localhost:1313/ServiceTest/VehicleService/mex

The WcfTestClient is almost certainly doing that to retrieve the WSDL so it can generate the proxy to the service.

Sixto Saez
  • 12,610
  • 5
  • 43
  • 51