我尝试使用多线程实现WCF Discovery服务。
static void InvokeService()
{
var Services = discoveryClient.Find(new FindCriteria(typeof(WCFDiscoveryContract.IService1)));
discoveryClient.Close();
ServiceClient.ServiceReference1.Service1Client client = new ServiceClient.ServiceReference1.Service1Client();
client.Endpoint.Address = Services.Endpoints[0].Address;
var loanResponses = new MultiThreadedServiceCall<IService1, int, string>()
.CallMethod((service, request) => service.GetData(request))
.AttachService(new ServiceClient.ServiceReference1.Service1Client())
.GetResults(111);
string ss = client.GetData(1);
Console.WriteLine("Data is " + ss);
}
当我发现托管在同一台机器上的服务时,它与输出工作正常。 但是当我使用托管在同一网络中的另一台机器上的服务时,它会在以下行中引发错误。
string ss = client.GetData(1);
错误是
SecurityNegotiationException未处理
该服务未对呼叫者进行身份验证。
无法满足安全令牌请求,因为身份验证失败。
我使用wsHttpBinding。
请注意,wcf发现服务适用于托管在另一台计算机上的服务。