private IList <UddiLookupResponse> GetUddiResponses(LookupParameters lookupParameters) { bool filterResponseByProfile = lookupParameters.ProfileIds != null; IList <UddiLookupResponse> lookupResponses = new List <UddiLookupResponse>(); UddiLookupKey key = new UddiLookupKey(lookupParameters.Identifier, lookupParameters.ServiceId, this.uddiProxy.Endpoint.Address.Uri, lookupParameters.ProfileConformanceClaim); IList <UddiService> uddiServices; if (!uddiServiceCache.TryGetValue(key, out uddiServices)) { uddiServices = this.GetUddiServices(lookupParameters.Identifier, lookupParameters.ServiceId, lookupParameters.ProfileConformanceClaim); if (uddiServices.Count > 0) { uddiServiceCache.Set(key, uddiServices); } } UddiLookupResponse lookupResponse; foreach (UddiService uddiService in uddiServices) { if (uddiService.IsInactiveOrExpired()) { continue; } else { IEnumerable <UddiBinding> supportedBindings = uddiService.Bindings; if (filterResponseByProfile) { supportedBindings = uddiService.GetBindingsSupportingOneOrMoreProfileAndRole(lookupParameters.ProfileIds, lookupParameters.ProfileRoleIdentifier); } foreach (UddiBinding uddiBinding in supportedBindings) { lookupResponse = GetLookupResponse(lookupParameters, uddiService, uddiBinding); lookupResponses.Add(lookupResponse); } } } return(lookupResponses); }
/*private static System.TimeSpan CreateTimeSpan(string key, int days, int hours, int minutes, int seconds) * { * TimeSpan cacheTime; * * string value = ConfigurationManager.AppSettings[key]; * if (string.IsNullOrEmpty(value)) * { * // not defined, using default cache time * cacheTime = new TimeSpan(days, hours, minutes, seconds); * } * else * { * if (System.TimeSpan.TryParse(value, out cacheTime)) * { * // values succesfull parsed to boolean * } * else * { * // parsing to TimeSpan failed * // using default cache time * cacheTime = new TimeSpan(days, hours, minutes, seconds); * } * } * * return cacheTime; * }*/ /// <summary> /// Translates a business level key ("EndpointKey", e.g. an EAN number) to an endpoint address (e.g. an URL). /// </summary> public List <UddiLookupResponse> Lookup(LookupParameters lookupParameters) { if (lookupParameters == null) { throw new ArgumentNullException("lookupParameters"); } List <UddiLookupResponse> supportedResponses = new List <UddiLookupResponse>(); IList <UddiLookupResponse> uddiLookupResponses = GetUddiResponses(lookupParameters); foreach (UddiLookupResponse uddiLookupResponse in uddiLookupResponses) { bool hasAcceptedTransportProtocol = HasAcceptedTransportProtocol(uddiLookupResponse, lookupParameters); if (hasAcceptedTransportProtocol) { supportedResponses.Add(uddiLookupResponse); } } return(supportedResponses); }
private bool HasAcceptedTransportProtocol(UddiLookupResponse uddiLookupResponse, LookupParameters lookupParameters) { EndpointAddress address = uddiLookupResponse.EndpointAddress; bool result = lookupParameters.AcceptedTransportProtocols.Contains(address.EndpointAddressTypeCode); return(result); }