C# WCF服务身份验证失败

C# WCF服务身份验证失败,c#,asp.net,web-services,wcf,C#,Asp.net,Web Services,Wcf,我正在尝试在我的控制台应用程序中使用WCF服务。 我的App.Config文件如下所示 <configuration> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> </startup> <system.serviceModel> <bindings> <wsHttpBind

我正在尝试在我的控制台应用程序中使用WCF服务。 我的App.Config文件如下所示

<configuration>
<startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
    <bindings>
        <wsHttpBinding>
            <binding name="WSHttpBinding_InventItemGroupService" />
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://mydomain.com/MicrosoftDynamicsAXAif50/inventitemgroupservice.svc"
            binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_InventItemGroupService"
            contract="ServiceReference1.InventItemGroupService" name="WSHttpBinding_InventItemGroupService">
            <identity>
                <userPrincipalName value="asd@as" />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>
对我来说一切似乎都很好,但它总是抛出一个错误

The caller was not authenticated by the service.

有人能指出我遗漏了什么吗?

1转到您的客户项目属性

a。转到“服务”选项卡

启用此设置并使用身份验证模式窗口

2使用这两个示例行更改客户端项目内的app.config文件

      <security mode="None">
        <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
        <message clientCredentialType="Windows" negotiateServiceCredential="false" algorithmSuite="Default" establishSecurityContext="false" />
      </security>
      <security mode="None">
        <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
        <message clientCredentialType="Windows" negotiateServiceCredential="false" algorithmSuite="Default" establishSecurityContext="false" />
      </security>
<security mode="None">
            <message clientCredentialType="Windows" negotiateServiceCredential="false" algorithmSuite="Default" establishSecurityContext="false" />
          </security>
           Service1Client client = new Service1Client();
            client.ClientCredentials.Windows.ClientCredential.UserName = "ETLIT-1";
            client.ClientCredentials.Windows.ClientCredential.Password = "etl";
            client.ClientCredentials.Windows.AllowNtlm = false;
            client.ClientCredentials.Windows.ClientCredential.Domain = "ETLIT-1-PC";
            Console.WriteLine(client.addNumber(23, 2));