WCF error: The caller was not authenticated by the

2019-01-07 09:28发布

I am trying to access my WCF service on a server from my client console application for testing. I am getting the following error:

The caller was not authenticated by the service

I am using wsHttpBinding. I'm not sure what kind of authentication the service is expecting?



<behaviors>
  <serviceBehaviors>
    <behavior name="MyTrakerService.MyTrakerServiceBehavior">
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpGetEnabled="true"/>
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

Update It works if I change my binding to <endpoint "basicHttpBinding" ... /> (from wsHttpBinding) on the IIS 7.0 hosted, windows 2008 server

11条回答
beautiful°
2楼-- · 2019-01-07 09:50

I was able to resolve the shared issue by following below steps:

  1. Go to IIS-->Sites-->Your Site-->
  2. Features View Pane-->Authentication
  3. Set Anonymous Authentication to Disabled
  4. Set Windows Authentication to Enabled

enter image description here

查看更多
贼婆χ
3楼-- · 2019-01-07 09:51

set anonymous access in your virtual directory

write following credentials to your service

ADTService.ServiceClient adtService = new ADTService.ServiceClient();
adtService.ClientCredentials.Windows.ClientCredential.UserName="windowsuseraccountname";
adtService.ClientCredentials.Windows.ClientCredential.Password="windowsuseraccountpassword";
adtService.ClientCredentials.Windows.ClientCredential.Domain="windowspcname";

after that you call your webservice methods.

查看更多
Ridiculous、
4楼-- · 2019-01-07 09:54

I also had the same problem in wsHtppBinding. And I just had to add security mode pointing to none, that solved my problem and no need to switch to basicHttpBinding. Check Here and check how to disable WCF security. Check the below config change for reference:

<wsHttpBinding>
    <binding name="soapBinding">
        <security mode="None">
            <transport clientCredentialType="None" />
            <message establishSecurityContext="false" />
        </security>
    </binding>
</wsHttpBinding>
查看更多
The star\"
5楼-- · 2019-01-07 09:54

Why can't you just remove the security setting altogether for wsHttpBinding ("none" instead of "message" or "transport")?

查看更多
再贱就再见
6楼-- · 2019-01-07 10:00

Have you tried using basicHttpBinding instead of wsHttpBinding? If do not need any authentication and the Ws-* implementations are not required, you'd probably be better off with plain old basicHttpBinding. WsHttpBinding implements WS-Security for message security and authentication.

查看更多
登录 后发表回答