简体   繁体   中英

Why am I getting this error when trying to connect to my WCF service

The caller was not authenticated by the service.

I have a WCF service hosted in a windows service on one machine and I have another windows service on a different machine as a client connecting to the WCF service on the first machine. I'm guessing it has something to do with security, but I'm not sure what to do. Here is the app.config of the client:

<system.serviceModel>
    <bindings>
        <wsDualHttpBinding>
            <binding name="WSDualHttpBinding_IWCFService" 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">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
                              maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
                <reliableSession ordered="true" inactivityTimeout="00:10:00"/>
                <security mode="Message">
                    <message clientCredentialType="Windows" negotiateServiceCredential="true" 
                             algorithmSuite="Default"/>
                </security>
            </binding>
        </wsDualHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://localhost:8731/Design_Time_Addresses/WCF/WCFService/" 
                  binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IWCFService" 
                  contract="WCFService.IWCFService" name="WSDualHttpBinding_IWCFService">
            <identity>
                <dns value="localhost"/>
            </identity>
        </endpoint>
    </client>
</system.serviceModel>

And the app.config of the service:

<system.serviceModel>
<services>
  <service name="WCF.WCFService" behaviorConfiguration="WCFBehavior">
    <endpoint address="" binding="wsDualHttpBinding" contract="WCF.IWCFService">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint
      address="mex"
      binding="mexHttpBinding"
      bindingConfiguration=""
      contract="IMetadataExchange"/>
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8731/Design_Time_Addresses/WCF/WCFService/" />
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="WCFBehavior">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>

What do I need to do to be able to connect to my WCF service.

One other thing to note is I created a simple console app as a client to the wcf service and it is able to connect to the service without a problem and the app.config file looks identical. Maybe is has something to do with the client service running as a different user? I am ok with removing any and all security, but don't know how.

The Console application is probably running with your credentials, the Windows Service that cannot connect with the wcf service is probably running with the local system account. Try installing the service with authentication mode "user" and your credentials

两件事:检查上面的身份,并确保您的其他服务不是以本地用户身份运行(默认!例如NetworkService),而是以域用户身份运行或重新考虑您的设置(您可以通过在您的帐户下运行该服务来进行测试)如果您在域中拥有所需的权利)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM