2012-03-20 80 views
0

我在IIS中創建了一個帶SSL證書的WCF服務。 Iam能夠看到它的頁面,但Iam無法使用它。要麼如果我想從網站打開wsdl什麼也沒有發生。當我嘗試從客戶端的服務參考我有錯誤無法從服務讀取WSDL

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

web.config文件在網站根

<?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文件

<% @ServiceHost 
Debug="true" 
Language="C#" 
Factory="DP.IPagac.Application.LegalEntityServiceHostFactory" 
Service="ApplicationContract.ProgramLayerContract.LegalEntityApplicationService" %> 
+0

「沒有終點傾聽」是你所需要的解決。看起來服務沒有運行。 – 2012-03-20 16:38:22

+0

但iam能夠在資源管理器中打開以.svc結尾的頁面。這意味着它正在運行,不是嗎?還是有更多的事情要做? – Ivan 2012-03-20 16:53:01

+0

Windows資源管理器或Internet Explorer?此外,該頁面可能會被緩存。 – 2012-03-20 17:31:26

回答

0

你有正確的想法https與行

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

但是,除非我錯過了某些東西,沒有mex端點(由錯誤指定)爲消費者提供wsdl。提供額外 MEX終結點,如:

<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> 
+0

我加了端點但沒有改變。但謝謝你的回答 – Ivan 2012-03-20 19:26:45