我在应用程序中执行实现时遇到问题。我有一些可以在Visual Studio中正常工作、运行和访问其信息的its服务。
例如,可以通过IE访问与are服务地址的连接,并且服务是正常的。
我在应用程序中执行可执行文件,当它试图访问get服务时,我得到403 (禁止)错误。
凭据很好,因为触发错误的行是在身份验证完成后使用webservice的方法时触发的。
即使在应用程序中以管理员权限运行,它也会显示相同的错误。并且WCF服务由本地管理员用户运行。
我已经尝试在与正在使用的方法相同的作用域中请求,但没有成功。
private SI_Out_SyncClient WebserviceConnection ()
{
BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);
binding.MaxBufferSize = 2147483647;
binding.MaxReceivedMessageSize = 2147483647;
binding.CloseTimeout = new TimeSpan(1, 5, 0);
binding.OpenTimeout = new TimeSpan(1, 5, 0);
binding.SendTimeout = new TimeSpan(1, 5, 0);
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.Basic;
EndpointAddress address = new EndpointAddress(Library.Environment.GetGlobalString("ENDPOINT"));
var client = new SI_Out_SyncClient(binding, address);
client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
client.ClientCredentials.UserName.UserName = Library.Environment.GetGlobalString("USER");
client.ClientCredentials.UserName.Password = Library.Environment.GetGlobalString("PASSWORD");
return client;
}我希望在应用程序中运行,因为我可以在debug中运行,但以正确的方式运行,而不是将debug编译模式设置为true。
提前感谢!
发布于 2019-05-28 20:57:09
我知道是怎么回事了。
在我的例子中,运行WCF服务的管理员用户没有访问互联网。
这是一个愚蠢的错误,但值得注册,因为我在研究中没有发现这样的方向。
https://stackoverflow.com/questions/56330700
复制相似问题