LorenzoGi
LorenzoGi

Reputation: 276

WCF service metadata (wsdl) cannot be accessed: error 400

I have a problem with WCF metadata on a new installation ( IIS 10 on Windows Server 2016)

Situation

Below an extract of web.config

<services>
      <service behaviorConfiguration="ServiceBehavior" name="...">
        <endpoint address="https://<fqdn>/ServiceA/ServiceA.svc"
                  binding="wsHttpBinding"
                  bindingConfiguration="wsHttpEndpointBinding"
                  name="WsHttpBinding"
                  contract="ServiceContracts.IServiceA">
        </endpoint>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
          <serviceMetadata httpsGetEnabled="true" httpGetEnabled="false" />
    ...

Could it be something linked to name resolution? The PC name is AAAAAA, the FQDN is BBBBB.domain.ext

Thanks for any suggestion L.

Upvotes: 0

Views: 540

Answers (1)

Ding Peng
Ding Peng

Reputation: 3974

The WCF service deployed in IIS does not need to set the endpoint address in web.config.

Here is my demo:

<?xml version="1.0"?>
<configuration>

  <appSettings/>
  <connectionStrings/>
  <system.web>
    <compilation debug="true">
    </compilation>
    <!--
        The <authentication> section enables configuration 
        of the security authentication mode used by 
        ASP.NET to identify an incoming user. 
    -->
    <authentication mode="Windows" />
    <!--
        The <customErrors> section enables configuration 
        of what to do if/when an unhandled error occurs 
        during the execution of a request. Specifically, 
        it enables developers to configure html error pages 
        to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
         <error statusCode="403" redirect="NoAccess.htm" />
         <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
      -->
  </system.web>
  <system.webServer>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>
  </system.webServer>
  <system.serviceModel>
    <services>
      <service name="WcfService25.Service1" behaviorConfiguration="WcfService25.Service1Behavior">
        <!-- Service Endpoints -->
        <endpoint address="" binding="basicHttpBinding" contract="WcfService25.IService1">
          <!-- 
              Upon deployment, the following identity element should be removed or replaced to reflect the 
              identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
              automatically.
          -->
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="WcfService25.Service1Behavior">
          <!-- To avoid disclosing metadata information, set the value below to false 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>

This is web.config. This project is a template project.

The base address of the WCF service in IIS is as follows:

enter image description here

enter image description here

enter image description here

Upvotes: 1

Related Questions