1
votes

I created a WCF service with SSL certificate in IIS. Iam able to see the page of it but iam not able to consume it. Either if i want to open the wsdl from website nothing happens. When I try to create a service reference from client I got error

Metadata contains a reference that cannot be resolved: 'https://win-1bmal4qsmmk/IPagac/LegalEntityApplicationService.svc?wsdl'.
The document format is not recognized (the content type is 'text/html; charset=UTF-8'). Metadata contains a reference that cannot be resolved: 'https://win-1bmal4qsmmk/IPagac/LegalEntityApplicationService.svc?wsdl'. There was no endpoint listening at https://win-1bmal4qsmmk/IPagac/LegalEntityApplicationService.svc?wsdl that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. The remote server returned an error: (404) Not Found. If the service is defined in the current solution, try building the solution and adding the service reference again.

enter image description here

the web.config file

<?xml version="1.0"?>
<configuration>
  <connectionStrings>
    <add name="DPMembershipConnection" connectionString="Data Source=localhost; Initial Catalog=data; Integrated Security=True; Pooling=False" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <system.web>
    <roleManager enabled="true" defaultProvider="DPRoleManager">
      <providers>
        <add name="DPRoleManager" type="System.Web.Security.SqlRoleProvider" connectionStringName="DPMembershipConnection" applicationName="/" />
      </providers>
    </roleManager>
    <authentication mode="Forms" />
    <compilation debug="true" targetFramework="4.0" />
    <membership defaultProvider="DPMembership">
      <providers>
        <add applicationName="/" connectionStringName="DPMembershipConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="4" name="DPMembership" passwordStrengthRegularExpression="" type="System.Web.Security.SqlMembershipProvider" />
      </providers>
    </membership>
  </system.web>
  <system.serviceModel>
    <bindings>
      <ws2007HttpBinding>
        <binding name="BindingName">
          <security mode="TransportWithMessageCredential">
            <transport clientCredentialType="None" />
            <message clientCredentialType="UserName" />
          </security>
        </binding>
      </ws2007HttpBinding>
    </bindings>
    <services>
      <service name="ApplicationContract.WCFContract.LegalEntityApplicationService">
        <endpoint address="https://localhost/IPagac/LegalEntityService.svc"
          behaviorConfiguration="NewBehavior0" binding="ws2007HttpBinding"
          bindingConfiguration="BindingName" name="Endpoint" contract="ApplicationContract.WCFContract.ILegalEntityApplicationService" />
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="NewBehavior0" />
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
          <serviceAuthorization principalPermissionMode="UseAspNetRoles"
            roleProviderName="AspNetSqlRoleProvider" />
          <serviceCredentials>
            <userNameAuthentication userNamePasswordValidationMode="MembershipProvider"
              membershipProviderName="AspNetSqlMembershipProvider" />
          </serviceCredentials>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="false"/>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

svc file in root of web site

<% @ServiceHost 
Debug="true" 
Language="C#" 
Factory="DP.IPagac.Application.LegalEntityServiceHostFactory" 
Service="ApplicationContract.ProgramLayerContract.LegalEntityApplicationService" %>
1
"No endpoint listening" is what you need to resolve. It seems the service is not running. - John Saunders
but iam able to open page ends with .svc in explorer. it means it is running, no? or there is more to do? - Ivan
Windows Explorer, or Internet Explorer? Also, the page might be cached. - John Saunders
Internet Explorer. Iam able to open localhost/IPagac/xyz.svc but when I click on the link to wsdl, page just refresh and nothing happens. I cleared cache also. - Ivan

1 Answers

0
votes

You have the right thought for https with the line

 <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" /> 

But unless I missed something, there is no mex endpoint (as specified by the error) which provides the consumer with a wsdl. Provide an additional mex endpoint such as:

<services> 
    <service name="ApplicationContract.WCFContract.LegalEntityApplicationService">    
        <endpoint address="https://localhost/IPagac/LegalEntityService.svc"    
          behaviorConfiguration="NewBehavior0" binding="ws2007HttpBinding"    
          bindingConfiguration="BindingName" name="Endpoint"    
          contract="ApplicationContract.WCFContract.ILegalEntityApplicationService" />    

         <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" /> 

    </service>
</services>