0
我想在我的控制檯應用程序中使用WCF服務。 我App.config文件看起來像這樣WCF服務身份驗證失敗
<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="[email protected]" />
</identity>
</endpoint>
</client>
</system.serviceModel>
控制檯應用程序代碼,以使身份驗證的一部分。
protected ProgramClass(AifSos.InventItemGroupServiceClient inventItemGroupServiceClient) // Constructor
{
MInventItemGroupServiceClient = inventItemGroupServiceClient;
// ReSharper disable once PossibleNullReferenceException
MInventItemGroupServiceClient.ClientCredentials.Windows.ClientCredential.UserName = "un";
MInventItemGroupServiceClient.ClientCredentials.Windows.ClientCredential.Password = "pw";
MInventItemGroupServiceClient.ClientCredentials.Windows.ClientCredential.Domain = "domain";
}
一切似乎都沒有問題啊,但它總是拋出一個錯誤
The caller was not authenticated by the service.
任何一個能指出我錯過了什麼?