I have a WCF hosted in a Windows Service and running with user domain account.
All my clients (Console applicatio or Web Applications) in the domain work very well.
I have a console application that is not in the domain that does not work.
Herei is the error :
Exception non gérée : System.ServiceModel.Security.SecurityNegotiationException:
L'appelant n'a pas été authentifié par le service. ---> System.ServiceModel.Fau
ltException: The request for security token could not be satisfied because authe
ntication failed.
Here is the WCF Server config :
<wsHttpBinding>
<binding name="TransactionalBind" transactionFlow="true"/>
</wsHttpBinding>
[...]
<endpoint address="http://machine.domain.fr:1083/MyService/"
binding="wsHttpBinding"
bindingConfiguration="TransactionalBind"
contract="MyService.IMyService"/>
[...]
<behavior name="MyBahavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="True" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
Here is my client config :
<wsHttpBinding>
<binding name="WSHttpBinding_IMyService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="true" 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>
[...]
<client>
<endpoint address="http://machine.domain.fr:1083/MyService/"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMyService"
contract="wsArchi.IMyService" name="WSHttpBinding_IMyService">
</endpoint>
</client>
Can you help me please ?
Many Thanks
Try using BasicHttpBinding...
I was facing issues when i used WSHttpBinding....
BasicHttpBinding solved my problem.!!!
Related
I have WCF hosted under website application at IIS. Below is service declarations in web.config
<system.serviceModel>
<services>
<service name="Emp.Depart.Handle">
<endpoint behaviorConfiguration="HandleBehavior" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IHandle"
contract="Emp.Depart.IHandle" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="HandleBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="HandleBehaviors">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IHandle" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
Despite of the previous declarations i got the error :
WCF The remote server returned an unexpected response: (400) Bad Request
when trying to connect from client, cofig of client is as follows :
<basicHttpBinding>
<binding name="BasicHttpBinding_Ihl7" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:05:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483646" maxBufferPoolSize="2147483646" maxReceivedMessageSize="2147483646"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483646" maxStringContentLength="2147483646" maxArrayLength="2147483646"
maxBytesPerRead="2147483646" maxNameTableCharCount="2147483646" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
I can't identify the cause of the problem, i searched and increased maxRecievedMessage but nothing happened.
Please advice.
not nice and also strange way, but removing the name of the configuration may work bases on: WCF service maxReceivedMessageSize basicHttpBinding issue
also these could be useful:
how to increase MaxReceivedMessageSize when calling a WCF from C#
http://msdn.microsoft.com/en-us/library/ee358768.aspx/
I wrote a self-hosted WCF service. When I run the server and the client, the client connects well. I rewrote the server as a Windows service. Now when I run the server and the client, the server is started, but the client fails upon request method with the error
The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was
Windows service is registered as LocalSystem. Server config:-
<system.serviceModel>
<services>
<service behaviorConfiguration="MyServiceTypeBehaviors" name="UCSService.UCSModule">
<endpoint address="" binding="basicHttpBinding" contract="UCSService.IUCSModule">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:9000/"/>
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceTypeBehaviors">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpEndpointBinding" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
Client config:-
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpEndpointBinding" closeTimeout="00:01:00"
openTimeout="00:00:30" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxBufferSize="65536" maxReceivedMessageSize="65536"
textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"
messageEncoding="Text">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://192.168.101.123:9000/" binding="basicHttpBinding"
bindingConfiguration="BasicHttpEndpointBinding" contract="UCSModuleClient.IUCSModule"
name="BasicHttpBinding_UCSModule" />
</client>
</system.serviceModel>
As I understand it, the main problem is that the server has become the service, but how to solve the problem I do not know. How can I resolve this problem?
Can you use google in the following fashion: https://www.google.com.bh/search?q=The+HTTP+request+is+unauthorized+with+client+authentication+scheme+%27Negotiate%27.&oq=The+HTTP+request+is+unauthorized+with+client+authentication+scheme+%27Negotiate%27.&aqs=chrome..69i57.384j0j7&sourceid=chrome&es_sm=93&ie=UTF-8
Possible solution: Try to run the service with the user Administrator
im tring to create fileTransfer base on this post
when i test it on local it work great
i set my service on the server using iis without ssl
this is my server config:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true"/>
<bindings>
<wsHttpBinding>
<binding name="TransferService" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<security mode="None" />
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="TransferServiceBehavior" name="WcfFTP.FtpService">
<endpoint address="FtpService.svc" binding="wsHttpBinding" bindingConfiguration="TransferService" contract="WcfFTP.IFileTransfer"/>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="TransferServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceThrottling maxConcurrentCalls="500" maxConcurrentSessions="500" maxConcurrentInstances="500"/>
</behavior>
</serviceBehaviors>
</behaviors>
and thats my client:
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IFileTransfer" 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="TransportWithMessageCredential">
<transport clientCredentialType="Digest" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://www.myhost.com/WsFTP/FtpService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IFileTransfer"
contract="FtpWcfClient.IFileTransfer" name="WSHttpBinding_IFileTransfer" />
</client>
iv been tring some help on the net with this security issue but this error seems to be strang
You binding configuration for client and server are incompatible. The server specifies no security but the client specifies TransportWithMessageCredential. Can you set security mode in client config to None.
I strongly suggest you to use WCF configuration editor too, which save you against many common mistakes such as misspellings, mismatch binding etc.
Never had problems before but after upgrading to .NET 4, I am getting "Access is Denied" when trying to invoke a WCF method over HTTPS. If I use HTTP instead of HTTPS, everything works fine. Any possible solutions for this? I can provide more specific information if requested.
web.config
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="some_product.SomeServiceAspNetAjaxBehavior">
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="some_product.SomeServiceAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<services>
<service name="some_product.SomeService">
<endpoint address="" behaviorConfiguration="some_product.SomeServiceAspNetAjaxBehavior" bindingConfiguration="BasicHttpBinding_SomeService" binding="webHttpBinding" contract="some_product.SomeService"/>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpsBinding_SomeService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="true" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192"
maxArrayLength="16384" maxBytesPerRead="4096"
maxNameTableCharCount="16384"/>
<security mode="Transport">
<transport clientCredentialType="Windows"
proxyCredentialType="None" realm=""/>
</security>
</binding>
<binding name="BasicHttpBinding_SomeService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="true" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="BasicHttpBinding_SomeService" maxReceivedMessageSize="300000" allowCookies="true" >
<readerQuotas maxStringContentLength="300000" />
</binding>
</webHttpBinding>
</bindings>
<client>
<endpoint address="/someurl/SomeService.svc" binding="webHttpBinding" bindingConfiguration="BasicHttpBinding_SomeService" contract="some_product.SomeService" name="BasicHttpBinding_SomeService"/>
<endpoint address="/someurl/SomeService.svc" binding="webHttpBinding" bindingConfiguration="BasicHttpsBinding_SomeService" contract="some_product.SomeService" name="BasicHttpsBinding_SomeService"/>
</client>
</system.serviceModel>
Note: Works PERFECTLY fine over HTTP. Problem ONLY exists under HTTPS.
With your setup, you have no security defined -- thus you can only connect using http:
<basicHttpBinding>
<binding name="BasicHttpBinding_SomeService" .....>
<readerQuotas maxDepth="32" maxStringContentLength="8192"
maxArrayLength="16384" maxBytesPerRead="4096"
maxNameTableCharCount="16384"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName" algorithmSuite="Default"/>
</security>
</binding>
</basicHttpBinding>
If you want to use https, you need to enable transport security:
<basicHttpBinding>
<binding name="BasicHttpBinding_Secure" .....>
<readerQuotas ..../>
<security mode="Transport">
<transport clientCredentialType="Windows"
proxyCredentialType="None" realm=""/>
</security>
</binding>
</basicHttpBinding>
Update: Now that you have defined your secure HTTPS binding configuration:
<bindings>
<basicHttpBinding>
<binding name="BasicHttpsBinding_SomeService" ......>
<readerQuotas ......../>
<security mode="Transport">
<transport clientCredentialType="Windows"
proxyCredentialType="None" realm=""/>
</security>
you also need to configure an endpoint to use that binding configuration, of course!
<services>
<service name="some_product.SomeService">
<endpoint
address=""
behaviorConfiguration="some_product.SomeServiceAspNetAjaxBehavior"
binding="webHttpBinding"
bindingConfiguration="BasicHttpBinding_SomeService"
contract="some_product.SomeService"/>
<!-- add this endpoint !! -->
<endpoint
address="secure"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpsBinding_SomeService"
contract="some_product.SomeService"/>
</service>
</services>
Just defining the binding configuration without having an endpoint that actually refers to it doesn't really help......
I'm using Service WCF, and I get the following error:
The security context token is expired or is not valid. The message was not processed.
Client config
<endpoint address="http://probiz:49610/GestionOrganizacion.svc"
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IOrganizacion"
contract="CarWin.ServiceContracts.Interfaces.IOrganizacion"
behaviorConfiguration="NewBehavior"
name="PRO_WSHttpBinding_IOrganizacion">
<identity>
<dns value="localhost" />
</identity>
<binding name="WSHttpBinding_IOrganizacion" closeTimeout="00:30:00"
openTimeout="00:30:00" receiveTimeout="00:30:00" sendTimeout="00:30:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="2147483647"
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" establishSecurityContext="true" />
</security>
</binding>
more config:
<endpointBehaviors>
<behavior name="NewBehavior">
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</endpointBehaviors>
will enforce security on the message. If that is not needed, you might want to try See msdn for more info.