Reputation: 1383
There are similar/same questions on stackoverflow but none really helper. I'm trying to authenticate WPF user through WCF service, but when i call IdentityValidator, instantly this error is thrown
"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."
As much as I understand WCF (And I only have really limited knowledge of it) new WCF should generate endpoints by itself and well it did as long as I haven't tried adding identity validation in it.
My Service App namespace is 'Congregatio.ServiceApp', this is config:
<?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>
Tried changing endpoint as told in other similar questions, however then I got Content not supported exception
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 client 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>
Upvotes: 0
Views: 1450
Reputation: 73
i think this is a bug in the wcf stuff. it writes 2 endpoints for a single wcf. you should remove the extra one
Upvotes: 0
Reputation: 28530
By default, WCF will use basicHttpBinding
for an endpoint over http
. It looks like you are trying to use wsHttpBinding
, but there are no endpoints defined for it, nor does WCF know to use wsHttpBinding
as the default for any communication over http
.
There are two ways to resolve this. First, you can tell WCF to use wsHttpBinding
for any communication over http
in the <protocolMaping>
section of the service config file, like this:
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
<add binding="wsHttpBinding" scheme="http" />
</protocolMapping>
Note that this would effectively disable the basicHttpBinding
endpoint, as you have told WCF to use wsHttpBinding
for any http
endpoint that is not explicitly set to another http
binding. You will also get the default values for wsHttpBinding
, as there is no endpoint defined that uses the binding configuration you specified.
The second way is to define an endpoint explicitly in the service config that uses wsHttpBinding
in the <system.serviceModel>
section, like this:
<services>
<service name="Congregatio.ServiceApp">
<endpoint address="" binding="wsHttpBinding"
bindingConfiguration="AuthenticationBinding"
contract="CongregatioServiceReference.ICongregatioService" />
</service>
</services>
Note that the name
attribute needs to match the name attribute in the markup of the .svc file.
Upvotes: 1