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
Related
I have followed all the steps on showing the metadata using the config file but I still received
Metadata publishing for this service is currently disabled
Below is my config file.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IService1" 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="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="RedPillJob_Raw.Service1" behaviorConfiguration="MyServiceTypeBehaviors">
<endpoint address="http://xxx.xxx.xxx.xxx/DanRaw/Service1.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService1"
contract="IService1" name="BasicHttpBinding_IService1" />
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceTypeBehaviors" >
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
I am so lost now, I hope somebody can help me.
The only thing I'd suggest is trying setting your endpoint address to the actual URL your client devices would connect to, for instance:
http:/ /CatDogMouse:6666/DanRaw/Service1
I don't see any examples of MEX with a .SVC address.
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.!!!
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.
I am getting the following error
"The Address property on
ChannelFactory.Endpoint was null. The
ChannelFactory's Endpoint must have a
valid Address specified."
and I am not sure what I am doing wrong. Does anybody see know what is the reson of it? Below are my project's App.config Server and Client Side
Thank you for help, regards
<system.serviceModel>
<services>
<service name="Server.DualService" behaviorConfiguration="NetTcpBehavior">
<endpoint address=""
binding="netTcpBinding"
bindingConfiguration="DuplexBinding"
contract="Server.IDualService" />
<endpoint address="mex" binding="mexTcpBinding" contract="Server.IDualService" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8731/Service/DualService/" />
</baseAddresses>
</host>
</service>
<service name="Server.PhoneService" behaviorConfiguration="Server.PhoneServiceBehavior">
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="" contract="Server.IPhoneService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:4444/Service/PhoneService" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Server.DualServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="Server.PhoneServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="NetTcpBehavior">
<serviceThrottling maxConcurrentSessions="10000" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding name="DuplexBinding" sendTimeout="00:00:11">
<reliableSession enabled="true" />
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>
CLIENT SIDE
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="DefaultBinding_IPhoneService" 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="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="">
<extendedProtectionPolicy policyEnforcement="Never" />
</transport>
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="DefaultBinding_IDualService" 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="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="">
<extendedProtectionPolicy policyEnforcement="Never" />
</transport>
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="WSHttpBinding_IPhoneService" 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="">
<extendedProtectionPolicy policyEnforcement="Never" />
</transport>
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint binding="basicHttpBinding" bindingConfiguration="DefaultBinding_IPhoneService"
contract="IPhoneService" name="DefaultBinding_IPhoneService_IPhoneService" />
<endpoint binding="basicHttpBinding" bindingConfiguration="DefaultBinding_IDualService"
contract="IDualService" name="DefaultBinding_IDualService_IDualService" />
<endpoint address="http://localhost:4444/Service/PhoneService"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IPhoneService"
contract="ServiceReference2.IPhoneService" name="WSHttpBinding_IPhoneService">
<identity>
<userPrincipalName value="PANDZIA-PC\PANDZIA" />
</identity>
</endpoint>
</client>
</system.serviceModel>
There is some problem with your configuration. Server specifies DualService over net.tcp but client uses BasicHttpBinding and does not specify address. Also your client has configuration for more endpoint then your service expose and mex endpoint in DualService has incorrect contract (should be IMetadataExchange).
Only client endpoint for PhoneService looks correct.
Everything works, you were right :),Thank you once again , and below I am putting the correct configuration, maybe someday it will help to somebody, .. :D:D
On server side I ve corrected IMetadataExchange in endpoint :
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
and I changed alittle
<behavior name="NetTcpBehavior">
<serviceMetadata/>
<serviceThrottling maxConcurrentSessions="10000" />
</behavior>
On CLIENT SIDE I deleted most genereted code in retation with DualService and added
<endpoint name=""
address="net.tcp://localhost:8731/Service/DualService/"
binding="netTcpBinding"
bindingConfiguration="DuplexBinding"
contract="IDualService" />
where binding looks like :
<netTcpBinding>
<binding name="DuplexBinding" sendTimeout="00:00:05" >
<reliableSession enabled="true" />
<security mode="None" />
</binding>
</netTcpBinding>
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......