开发者

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

开发者 https://www.devze.com 2023-04-09 05:37 出处:网络
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 t
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>
      开发者_StackOverflow<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


two things: check the identity above and make sure that your other service is running not as a local-user (default! for example NetworkService) but as a domain user or rethink your settings (you can TEST this by running the service under your account if you got the needed rights in your domain)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号