/// <summary> /// Gets all endpoints. /// </summary> /// <returns>SerializableEndpoint[][].</returns> public SerializableEndpoint[] GetAllEndpoints() { using (var clt = CreateDiscoveryClient()) { try { var criteria = FindCriteria.CreateMetadataExchangeEndpointCriteria(); var resp = clt.Find(criteria); var serviceEndpoints = new List <SerializableEndpoint>(); foreach (var it in resp.Endpoints) { try { var sep = MetadataHelper.GetEndpoints(it.Address.Uri.AbsoluteUri); serviceEndpoints.AddRange(sep.Select(ep => new SerializableEndpoint(ep, 0))); } catch (Exception e) { FxLog <Discos> .LogException(e); } } return(serviceEndpoints.ToArray()); } catch (Exception ex) { FxLog <Discos> .LogException(ex); return(null); } finally { CloseClient(clt); } } }
/// <summary> /// Gets the endpoint discovery metadata. /// </summary> /// <param name="contractTypeName">Name of the contract type.</param> /// <returns>SerializableEndpoint[][].</returns> public SerializableEndpoint[] GetEndpoints(string contractTypeName) { using (var clt = CreateDiscoveryClient()) { try { var lst = new List <XmlQualifiedName>() { new XmlQualifiedName(contractTypeName) }; var criteria = FindCriteria.CreateMetadataExchangeEndpointCriteria(lst); var resp = clt.Find(criteria); var serviceEndpoints = new List <SerializableEndpoint>(); foreach (var it in resp.Endpoints) { serviceEndpoints.AddRange(MetadataHelper .GetEndpoints(it.Address.Uri.AbsoluteUri) .Select(ep => new SerializableEndpoint(ep, 0))); } return(serviceEndpoints.ToArray()); } catch (Exception ex) { FxLog <Discos> .LogException(ex); return(null); } finally { CloseClient(clt); } } }
//protected override void RegisterRequiredDomainObjects() //{ // _FxLog<DiscoSentry>.DebugFormat("Hello"); //} #region IDiscoService Members /// <summary> /// Gets all endpoints. /// </summary> /// <returns>SerializableEndpoint[][].</returns> public SerializableEndpoint[] GetAllEndpoints() { try { return(Business.DiscoProvider .Discos .GetAllEndpoints()); } catch (Exception exception) { FxLog <DiscoSentry> .LogException(exception); throw; } }
/// <summary> /// Saves the cloud contract. /// </summary> /// <param name="contract">The contract.</param> /// <returns>CloudContract.</returns> public CloudContract SaveCloudContract(CloudContract contract) { FxLog <CloudContracts> .DebugFormat("Registering service contract for [{0}]", contract.Id); try { contract = Provider <CloudContract> .Save(contract); } catch (Exception ex) { FxLog <CloudContracts> .LogException(ex); contract.AddError(ex.Message); } return(contract); }
/// <summary> /// Gets all endpoint addresses. /// </summary> /// <returns>DiscoItem[][].</returns> public DiscoItem[] GetAllEndpointAddresses() { using (var clt = CreateDiscoveryClient()) { try { var criteria = FindCriteria.CreateMetadataExchangeEndpointCriteria(); var resp = clt.Find(criteria); var addresses = new List <DiscoItem>(); foreach (var it in resp.Endpoints.Where(i => (i.Address.Uri.Scheme == Uri.UriSchemeHttp))) // only consider http mex endpoints { try { var sep = MetadataHelper.GetEndpoints(it.Address.Uri.AbsoluteUri); foreach (var ep in sep) { if (!ep.IsSystemEndpoint) { addresses.Add(new DiscoItem() { Id = Guid.NewGuid().ToString(), Endpoint = ep.Address.Uri.OriginalString, Contract = String.Format("{0}:{1}", ep.Contract.Namespace, ep.Contract.Name) }); } } } catch (Exception exp) { FxLog <Discos> .LogException(exp); } } return(addresses.ToArray()); } finally { CloseClient(clt); } } }
/// <summary> /// Saves the cloud contracts. /// </summary> /// <param name="contracts">The contracts.</param> /// <returns>CloudContract[][].</returns> public CloudContract[] SaveCloudContracts(CloudContract[] contracts) { var lst = new List <CloudContract>(); FxLog <CloudContracts> .DebugFormat("Registering Cloud Contracts:"); foreach (var cloudContract in contracts) { try { var res = SaveCloudContract(cloudContract); lst.Add(res); } catch (Exception ex) { FxLog <CloudContracts> .LogException(ex); cloudContract.AddError(ex.Message); lst.Add(cloudContract); } } return(lst.ToArray()); }
/// <summary> /// Creates the error address. /// </summary> /// <param name="it">It.</param> /// <param name="exp">The exp.</param> /// <returns>DiscoItem.</returns> private DiscoItem CreateErrorAddress(EndpointDiscoveryMetadata it, Exception exp) { try { var edi = new DiscoItem() { Id = Guid.NewGuid().ToString(), Endpoint = exp.Message, Contract = "Error in Service", }; edi.AddError(exp.Message); if (exp.InnerException != null) { edi.AddError(String.Format("Inner: {0}", exp.InnerException.Message)); } return(edi); } catch (Exception exep) { FxLog <Discos> .LogException(exep); return(null); } }