WCF - "Request for security token cannot be satisfied because authentication failed"

I created a WCF service and hosted it in IIS7 / Windows Server 2008. I try to use the service in my application ... When I start the application from Visual Studio (debug), I can call the service and everything works as expected, however, when I try to call a service from a published application, I get the error above.

Here is the web.config service:

<?xml version="1.0" encoding="utf-8" ?> <configuration> <connectionStrings> ... </connectionStrings> <system.web> <compilation debug="false" /> </system.web> <runtime> <generatePublisherEvidence enabled="false"/> </runtime> <system.serviceModel> <services> <service name="SVCLIB.SERVICE1"> <endpoint address="" binding="wsHttpBinding" contract="SVCLIB.SERVICE1"> <identity> <dns value="localhost" /> </identity> </endpoint> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> <host> <baseAddresses> <add baseAddress="http://localhost:8732/Design_Time_Addresses/SVCLIB/SERVICE1/" /> </baseAddresses> </host> </service> </services> <behaviors> <serviceBehaviors> <behavior name=""> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel> </configuration> 

And on the client:

  SERVICE1.SERVICE1Client objService = new SERVICE1Client(); objService.ClientCredentials.Windows.ClientCredential.UserName = "UserName"; objService.ClientCredentials.Windows.ClientCredential.Password = "Password"; objService.GetData(); objService.Close(); 

It works when debugging an application in VS, but when starting a published application, it does not work.

Error:

Security token request could not be satisfied because authentication failed

I looked through a lot of posts here about stack overflows and others, but so far no one has helped me.

Thanks!

** EDIT:

This is on the client.config web.config:

 <system.serviceModel> <bindings> <wsHttpBinding> <binding name="WSHttpBinding_SERVICE1" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" /> <security mode="Message"> <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" /> <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" /> </security> </binding> </wsHttpBinding> </bindings> <client> <endpoint address="http://server.samedomain.com:8000/SVCLIB.SERVICE1.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_SERVICE1" contract="SERVICE1.ISERVICE1" name="WSHttpBinding_ISERVICE1"> </endpoint> </client> </system.serviceModel> 

Tried the suggestion and gmail user link below ... but still has the same problem. The same mistake.

+4
source share
2 answers

I still don’t know what the problem is. But for now, I switched to basicHttpBinding with Windows authentication .

+1
source

I'm not sure, but try to comment on the following lines in a published environment

 <identity> <dns value="localhost" /> </identity> <host> <baseAddresses> <add baseAddress="http://localhost:8732/Design_Time_Addresses/SVCLIB/SERVICE1/" /> </baseAddresses> </host> 
0
source

Source: https://habr.com/ru/post/1440388/


All Articles