Search code examples
web-serviceswcfiissoapwsdl

WCF service on IIS - WSDL is empty


I created a WCF service and hosted it on my IIS server. Then, I needed to edit the schemaLocation. I followed this post.

When I add "?wsdl" to the url, I get an empty page. If I try to use the WSDL from SOAPui to test it, I get this "Error loading [http://xx.xxx.xx.xx:8095/CardServiceLib.CardService.svc/service?wsdl]: org.apache.xmlbeans.XmlException: org.apache.xmlbeans.XmlException: error: Unexpected end of file after nul"

If I delete the HTTPGetUrl, the WSDL is correct but the schemaLocation isn't what I want. With the mod I made with the linked post, the schemaLocation is perfect but the WSDL is empty... why?

This works, but not as I want (generates WSDL but with wrong links):

<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />

and this not (doesn't generate WSDL --> blank page!!!):

<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" httpGetUrl="http://xx.xx.xx.xx.:8095/MyService.svc/endpoint"/>

This is my web.config on IIS server 7

    <?xml version="1.0" encoding="utf-8"?>
<configuration>
  <connectionStrings>
    <add name="connectionString" connectionString="server=xxxxx;database=xxxxx;uid=xxxxx;pwd=xxxxx;" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
    <add key="userName" value="admin" />
    <add key="password" value="xxxxx" />
    <add key="ClientSettingsProvider.ServiceUri" value="" />
    <add key="SecurityKey" value="xxxxxxxxxx" />
  </appSettings>
  <system.web>
    <compilation debug="true" />
    <membership defaultProvider="ClientAuthenticationMembershipProvider">
      <providers>
        <add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
      </providers>
    </membership>
    <!--<roleManager defaultProvider="ClientRoleProvider" enabled="true">
      <providers>
        <add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
      </providers>
    </roleManager>-->
  </system.web>
  <system.serviceModel>
    <standardEndpoints>
        <webHttpEndpoint>
        <!-- the "" standard endpoint is used for auto creating a web endpoint. -->
        <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" />
      </webHttpEndpoint>
    </standardEndpoints>
    <bindings>
      <basicHttpBinding>
        <binding name="SecurityByTransport" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
          <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Basic" />
            <!--<message clientCredentialType="UserName"/>-->
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="CardServiceLib.CardService" behaviorConfiguration="customBehavior">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="SecurityByTransport" name="base" contract="CardServiceLib.ICardService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" name="mex" contract="IMetadataExchange" />
        <!--<endpoint address="web" behaviorConfiguration="webHttp" binding="webHttpBinding"
          bindingConfiguration="" name="web" contract="calc.ICalcService">
          <identity>
            <dns value="localhost" />httpGetUrl="http://77.108.40.77:8095/CardServiceLib.CardService.svc/service"
          </identity>
        </endpoint>-->
        <host>
          <baseAddresses>
            <add baseAddress="https://xx.xx.xx.xx:8095/MyService/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="webHttp">
          <webHttp />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
        <behavior name="customBehavior">
          <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" httpGetUrl="http://xx.xx.xx.xx:8095/MyService.Service.svc/service"/>
          <serviceDebug includeExceptionDetailInFaults="True" />
          <serviceCredentials>
            <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="xx,xx" />
          </serviceCredentials>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <!--<protocolMapping>
      <add binding="webHttpBinding" scheme="http"  />
    </protocolMapping>-->
  </system.serviceModel>
      <system.webServer>
        <directoryBrowse enabled="false" />
    </system.webServer>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />  </startup></configuration>

SOLVED!! I added this

address="http://192.168.1.2/Demo.Service/MultiEndPointsService.svc/basic"

in my endpoint tag, like written in this link.


Solution

  • I suspect the issue is related to the authentication required to access the WSDL.

    When attempting to access the metadata URL directly, the web site indicates the following:
    “Authentication Required”
    “The server http://...:8095 requires a username and password.”

    You either need to provide the proper credentials or relax the permissions on the WSDL.