wcf因为Windows服务失败而出错

时间:2014-10-02 10:24:46

标签: wcf

我写了一个自托管的WCF服务。当我运行服务器和客户端时,客户端连接良好。我将服务器重写为Windows服务。现在,当我运行服务器和客户端时,服务器已启动,但客户端因请求方法失败并显示错误

HTTP请求未经授权,客户端身份验证方案为“Negotiate”。从服务器收到的身份验证标头是

Windows服务注册为LocalSystem。服务器配置: -

<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>  

客户端配置: -

<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>

据我了解,主要问题是服务器已成为服务,但如何解决我不知道的问题。我该如何解决这个问题?