2015-11-26 2 views
0

Есть похожие/одинаковые вопросы о stackoverflow, но ни один из них не является помощником. Я пытаюсь для проверки подлинности пользователя WPF через WCF службы, но когда я называю IdentityValidator, мгновенно эта ошибка возникаетWCF Конечная точка не найдена для служебного интерфейса

"Could not find default endpoint element that references contract 
'CongregatioServiceReference.ICongregatioService' in the ServiceModel client 
configuration section. This might be because no configuration file was found for your 
application, or because no endpoint element matching this contract could be found 
in the client element." 

Насколько я понимаю, WCF (И у меня есть только очень ограниченное знание о нем) новый WCF должен генерировать конечные точки сам по себе, и это хорошо, если я не пробовал добавлять в него удостоверение личности.

My Service App пространства имен 'Congregatio.ServiceApp', это конфиг:

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 

    <configSections> 
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> 
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
    </configSections> 
    <appSettings> 
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> 
    <add key="owin:AutomaticAppStartup" value="false" /> 
    </appSettings> 
    <system.diagnostics> 
    <sources> 
     <source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true"> 
     <listeners> 
      <add name="xml" /> 
     </listeners> 
     </source> 
     <source name="System.ServiceModel.MessageLogging"> 
     <listeners> 
      <add name="xml" /> 
     </listeners> 
     </source> 
     <source name="myUserTraceSource" switchValue="Critical, Error, Warning"> 
     <listeners> 
      <add name="xml" /> 
     </listeners> 
     </source> 
    </sources> 
    <sharedListeners> 
     <add name="xml" type="System.Diagnostics.XmlWriterTraceListener" initializeData="Error.svclog" /> 
    </sharedListeners> 
    </system.diagnostics> 
    <system.web> 
    <compilation debug="true" targetFramework="4.5" /> 
    <httpRuntime targetFramework="4.5" /> 
    </system.web> 
    <system.serviceModel> 
    <bindings> 
     <wsHttpBinding> 
     <binding name="AuthenticationBinding"> 
      <security mode="Message"> 
      <message clientCredentialType="UserName" /> 
      </security> 
     </binding> 
     </wsHttpBinding> 
    </bindings> 
    <behaviors> 
     <serviceBehaviors> 

     <behavior> 
      <!-- To avoid disclosing metadata information, set the values below to false before deployment --> 
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="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="true" /> 
     </behavior> 
     <behavior name="authBehavior"> 
      <serviceCredentials> 
      <userNameAuthentication userNamePasswordValidationMode="Custom" 
            customUserNamePasswordValidatorType="Congregatio.ServiceApp.IdentityValidator,Congregatio.ServiceApp" /> 
      </serviceCredentials> 
      <serviceAuthorization principalPermissionMode="Custom" serviceAuthorizationManagerType="Congregatio.ServiceApp.RoleValidator,Congregatio.ServiceApp"> 
      </serviceAuthorization> 

     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <protocolMapping> 
     <add binding="basicHttpsBinding" scheme="https" /> 
    </protocolMapping> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 

    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true" /> 
    <!-- 
     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> 
    <entityFramework> 
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> 
    <providers> 
     <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> 
    </providers> 
    </entityFramework> 
    <runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0" /> 
     </dependentAssembly> 
    </assemblyBinding> 
    </runtime> 
    <connectionStrings> 
    <!-- Some connection strings i won't be sharing :(--> 
    </connectionStrings> 
</configuration> 

попытался изменить конечную точку, как сказано в других подобных вопросах, но потом я получил контент не поддерживается исключение

Content Type application/soap+xml; charset=utf-8 was not supported by service http://localhost:50767/Service1.svc. The client and service bindings may be mismatched 

WPF клиент enpoints:

<client> 
    <!--Default Working One--> 
      <endpoint address="http://localhost:50767/Service1.svc" binding="basicHttpBinding" 
       bindingConfiguration="BasicHttpBinding_ICongregatioService" 
       contract="CongregatioServiceReference.ICongregatioService" 
       name="BasicHttpBinding_ICongregatioService" /> 
    <!-- My messy one --> 
      <endpoint 
       name="AuthenticationBinding" 
       address="http://localhost:50767/Service1.svc" 
       binding="wsHttpBinding" 
       contract="CongregatioServiceReference.ICongregatioService" 
       /> 
     </client> 
+0

Ваш сервис, похоже, делает https, но ваш клиент вызывает http. Это по дизайну? – nvoigt

ответ

1

По умолчанию WCF будет использовать basicHttpBinding для конечной точки над http. Похоже, вы пытаетесь использовать wsHttpBinding, но для него не определены конечные точки, и WCF не знает, как использовать wsHttpBinding по умолчанию для любой связи за http.

Существует два способа решить эту проблему. Во-первых, вы можете сказать, WCF использовать wsHttpBinding для любой связи по http в <protocolMaping> разделе службы файла конфигурации, например:

<protocolMapping> 
    <add binding="basicHttpsBinding" scheme="https" /> 
    <add binding="wsHttpBinding" scheme="http" /> 
</protocolMapping> 

Обратите внимание, что это будет эффективно отключить basicHttpBinding конечную точку, как вы сказали WCF использовать wsHttpBinding для любой конечной точки http, которая явно не установлена ​​на другую привязку http. Вы также получите значения по умолчанию для wsHttpBinding, так как нет определенной конечной точки, которая использует указанную вами конфигурацию привязки.

Второй способ заключается в определении конечной точки явно в конфигурации службы, которая использует wsHttpBinding в разделе <system.serviceModel>, как это:

<services> 
    <service name="Congregatio.ServiceApp"> 
    <endpoint address="" binding="wsHttpBinding" 
       bindingConfiguration="AuthenticationBinding" 
       contract="CongregatioServiceReference.ICongregatioService" /> 
    </service> 
</services> 

Обратите внимание, что атрибут name должен соответствовать имени атрибута в разметке файл .svc.

0

Я думаю, что это ошибка в материале wcf. он записывает 2 конечных точки для одного wcf. вы должны удалить дополнительный один

Смежные вопросы