Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created WCF service hosted on IIS. I get the following error when browse the service.

Metadata publishing for this service is currently disabled.

Here is the code for web.config

XML
<?xml version="1.0"?>
<configuration>
    <system.web>
        <compilation debug="true" targetFramework="4.0"/>
    </system.web>
    <system.serviceModel>
        <services>
            <service behaviorConfiguration="ServiceBehavior" name="IISHostedServiceEx1.MyService">
                <endpoint address="http://localhost/IISHostedServiceEx1/MyService.svc" binding="wsHttpBinding" contract="IMyService">
                    <identity>
                        <dns value="localhost"/>
                    </identity>
                </endpoint>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
            </service>
        </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="ServiceBehavior">
                    <!-- 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>


    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
    </system.webServer>
</configuration>


Can any body tell me how can i resolve it?

thanks in advance.
Posted
Updated 26-Jul-16 22:46pm

Right click on your service reference and click configure and un-check "Reuse Types in Referenced Assemblies".
Second thing you need to have one extra endpoint ImetaDataExchange, If its not there then add in web.config.
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange">
 
Share this answer
 
I believe the problem is the address you're using for the wsHttpBinding element.
Generally, there's no need to specify the address, unless you actually want it to run in a subaddres of the actual .svc file, as below:

XML
<system.serviceModel>
  <services>
    <service behaviorConfiguration="ClientProcessadorEventos" name="ClienteExternoWS.ClientProcessadorEventos">
      <endpoint address="mex" binding="mexHttpBinding" name="Mex" contract="ServiceInterfaces.IProcessadorEventos"/>
      <endpoint address="basic" binding="basicHttpBinding" name="Basic" contract="ServiceInterfaces.IProcessadorEventos"/>
      <endpoint address="" binding="wsHttpBinding" name="Ws" contract="ServiceInterfaces.IProcessadorEventos"/>
    </service>
  </services>
  <behaviors>
    <serviceBehaviors>
      <behavior name="ClientProcessadorEventos">
        <serviceMetadata httpGetEnabled="true"/>
      </behavior>
    </serviceBehaviors>
  </behaviors>
</system.serviceModel>


In this case, my service exposes the same contract on the pure .svc address (root, as the address is not specified), and it also exposes as basicBinding on the [ServiceName].svc/Basic address.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900