private static Option <string> GetWsdlEndpoint(ServiceMetadata metadata) { var baseAddress = metadata.Host.BaseAddresses .Select(a => a.AbsoluteUri.EndsWith("/") ? a : new Uri(a.AbsoluteUri + "/")) .FirstOrDefault(a => a.Scheme == Uri.UriSchemeHttp); if (baseAddress == null) { return(Option.None <string>()); } return(metadata.Host.Description.Behaviors .Select(x => x as ServiceMetadataBehavior) .Where(x => x != null) .Where(x => x.HttpGetEnabled) .Select(x => new Uri(baseAddress, x.HttpGetUrl) + "?wsdl") .FirstOrNone()); }
private static ServiceMetadata SetUpService(Type serviceType) { var metadata = new ServiceMetadata { FullName = serviceType.FullName, Host = new ServiceHost(serviceType, new Uri[0]), }; metadata.MexEndpoints = metadata.Host.Description.Endpoints .Where(e => e.Contract.ContractType == typeof(IMetadataExchange)) .Select(e => e.Address.Uri.AbsoluteUri) .ToArray(); metadata.Endpoints = metadata.Host.Description.Endpoints .Where(e => e.Contract.ContractType != typeof(IMetadataExchange)) .Select(e => e.Address.Uri.AbsoluteUri) .ToArray(); GetWsdlEndpoint(metadata).Match( some: _ => metadata.WsdlEndpointAddress = _, none: () => { }); return(metadata); }