2011-05-24 83 views
3

有人知道如何设置发现超时。默认值是10-15s,它接缝有点长...WCF和服务发现超时

在女巫方面是否必须配置?服务?客户?

服务:

  // Add a ServiceDiscoveryBehavior 
      host.Description.Behaviors.Add(new ServiceDiscoveryBehavior()); 
      // Add a UdpDiscoveryEndpoint 
      host.AddServiceEndpoint(new UdpDiscoveryEndpoint()); 

客户:

EndpointAddress endPoint = null; 

    endPoint = FindCalculatorServiceAddress(); 

    static EndpointAddress FindCalculatorServiceAddress() 
    { 
     // Create DiscoveryClient 
     DiscoveryClient discoveryClient = new DiscoveryClient(new UdpDiscoveryEndpoint()); 

     // Find IStringReverser endpoints    
     FindResponse findResponse = discoveryClient.Find(new FindCriteria(typeof(IStringReverser))); 

     if (findResponse.Endpoints.Count > 0) 
     { 
      return findResponse.Endpoints[0].Address; 
     } 
     else 
     { 
      return null; 
     } 
    } 

在此先感谢

+0

顺便说一句,如果您通过FindProgressChanged和FindCompleted事件而不是同步的Find()方法使用FindAsync()方法,只要端点结果出现,就会触发FindProgressChanged事件这意味着您可以立即访问它们,而不必等到搜索结束。如果你对更多结果不感兴趣,或者只是让它运行到超时,那么你可以选择'CancelAsync()',此时'FindCompleted'触发。 – Alex 2015-02-06 06:47:40

回答