Need ASP.NET Web Service Application style default page in WCF Service Application (asmx vs svc) RRS feed

  • Question

  • I need to display the ASP.NET Web Service Application style default page which displays help for the supported operations in a WCF Service Application.

    Steps to Reproduce my problem:

    1. Start Visual Studio 2005 and create a new ASP.NET Web Service Application.  Build and then Run the WebService1 project (Right click on project and select Debug | Start new instance).  Add Service1.asmx to the URL of the default web page or click on it in the displayed directory list. The result is the following text:

    The following operations are supported.  For a formal definition, please review the Service Description. 

    Plus, a Description parameter can be added to the WebMethod attribute to provide help information.

    2. Start Visual Studio 2010 and create a new WCF Service Application.  Build and then Run the WcfService1 project.  Add Service1.svc to the URL of the default web page or click on it in the displayed directory list. The result is the following text:

    You have created a service.
    To test this service, you will need to create a client and use it to call the service. You can do this using the svcutil.exe tool from the command line with the following syntax:
    svcutil.exe http://localhost:51784/Service1.svc?wsdl
    This will generate a configuration file...blah blah blah.

    I need to see the same style default page in the WCF Service Application as they see in their ASP.NET Web Service Application.

    I've found many questions concerning this, but no relevant answers.  I do not want to change the servicemetadata URL with

    <serviceMetadatahttpGetEnabled="true" httpGetURL="whatever"/>

    because that would change the automatic configuration of a client when adding a service reference.

    Is there a setting available in the wcf service's web.config file like "useLegacyWebStyleDefaultPage"?

    Is there some way in code or config to replace just the default page and not change any of the servicemetadata functionality?

    Wednesday, April 29, 2015 6:37 PM

All replies

  • Hi Steven Wood,

      According to this case, I have shared the corresponding details below:

    1. As far as I know, there is no possibility to set defaultpage in WCF Service Application (svc) like asmx

    2. But you have an options to change the service metadata functionality

    3. if you want to provide a link to static metadata?
              An alternative is to leave metadata browsing enabled and provide a static file where the WSDL document can be retrieved. This is achieved by providing a value for the externalMetadataLocation attribute:

    <behavior name="serviceBehavior">

      <serviceDebug httpHelpPageEnabled="false" />

      <serviceMetadata httpGetEnabled="true" externalMetadataLocation="http://localhost/IISHostedService/"/>


    4. then Exporting metadata like below :
      To produce a static WSDL document, you can export service metadata using SvcUtil, as illustrated in this lab. SvcUtil uses the mex endpoint to retrieve service metadata and save it to a WSDL document that can be stored on the filesystem.

    The command switch for SvcUtil to export metadata is /t:metadata.
    This command dumps the service metadata to several .wsdl and .xsd files in the specified directory:

    svcutil /d:<YourLearningWCFPath>\Labs\Chapter1\IISHostedService /t:metadata http://localhost/IISHostedService/service.svc

    The service model spreads the service description across multiple files. These files have a hierarchical relationship where a root .wsdl imports child .wsdl and .xsd files. In reality they are all one service description if you denormalize the output. With this output, you can still use SvcUtil to generate code for client applications

    5.To know more about service metadata attributes & element, refer here:

    with regards,

    Thursday, April 30, 2015 9:06 AM
  • Hi Edwin. You have shared and for that I am thankful.  It does indeed appear that the default help page can only be turned off and not redirected.  It seems that the only way to solve this problem at this time is to provide a redirection service which only redirects GET requests which have no parameters to a separate URL where a custom help file can be served.

    But, it makes no sense to create a static WSDL.  No application has ever remained static for very long.  The WSDL is automatically created by WCF and is crucial to proper remote client configuration, so disabling this feature is very risky and prone to failure when the service is changed but not the WSDL.

    Also, I believe MEX is an acronym for Metadata EXchange and doesn't mean there needs to be a specific MEX endpoint.  By default WCF provides a basicHttpBinding endpoint.  You can check that by creating a new WCF Service Application using the steps above and running it then appending /mex at the end of the service URL and getting a HTTP 400 bad request from the web server.  I think ASP.NET Web Services included a mex endpoint by default, but all new efforts should be directed toward WCF services which provides ws-metadata by default through disco, wsdl, and xsd.

    According to the MSDN reference svcutil.exe uses ws-metadata and disco.  ws-metadata is available by appending ?wsdl, ?xsd=xsd0, ?xsd=xsd1, and ?xsd=xsd2, etc. to the end of the service URL.  And, appending ?disco provides the discovery exchange which provides the URL of the WSDL.  I believe mex provides the same information but in a different format and is the second method that svcutil.exe tries.

    It is interesting to note that a REST interface can be added to a WCF service which can provide a custom mex response.  But, I'm getting point is that the movement is toward a standard interface which all clients can use to discover and configure service requests and using a custom WSDL defeats that movement.

    Thursday, April 30, 2015 3:07 PM