0

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?

Khurram Ali
  • 1,627
  • 3
  • 19
  • 33
VJS
  • 139
  • 8
  • Follow this link i hope it will help you http://stackoverflow.com/questions/15570108/the-http-request-is-unauthorized-with-client-authentication-scheme-negotiate http://morrisbahrami.blogspot.com/2011/02/http-request-is-unauthorized-with.html – Khurram Ali Oct 03 '14 at 11:27
  • Well, I tried this (the one about IIS) but I still have the error. – VJS Oct 03 '14 at 13:12

1 Answers1

0

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

DJ'
  • 1,737
  • 1
  • 13
  • 26
  • My account has Administrator rights and including Administrators group. And Google search, of course I used it, but the most decisions about NTLM or IIS. – VJS Oct 02 '14 at 14:48
  • 1
    @VJS - Your account may have administrator rights, but does the account *running* the service have them? – Tim Oct 02 '14 at 19:47
  • I set that the service is running from Administrator account and have the same error. Also I tried fill ClientCredentials.UserName and ClientCredentials.Windows.ClientCredential with the same data on client side. – VJS Oct 03 '14 at 08:11