public static bool IsEndpointDefinedInConfiguration(string endpointName, Type contractType) { if (string.IsNullOrEmpty(endpointName)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("endpointName"); } if (contractType == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("contractType"); } bool wildcard = string.Equals(endpointName, "*", StringComparison.Ordinal); ClientSection section = ClientSection.GetSection(); foreach (ChannelEndpointElement element in section.Endpoints) { if ((!wildcard && (element.Name != endpointName)) || (element.Contract != contractType.FullName)) { continue; } return(true); } return(false); }
public WsdlImporter CreateDataContractSerializerImporter(MetadataSet metaData) { Collection <IWsdlImportExtension> wsdlImportExtensions = ClientSection.GetSection().Metadata.LoadWsdlImportExtensions(); for (int i = 0; i < wsdlImportExtensions.Count; i++) { if (wsdlImportExtensions[i].GetType() == typeof(XmlSerializerMessageContractImporter)) { wsdlImportExtensions.RemoveAt(i); } } return(new WsdlImporter(metaData, null, wsdlImportExtensions)); }
internal static TEndpoint LookupEndpointFromClientSection <TEndpoint>(string endpointConfigurationName) where TEndpoint : ServiceEndpoint { Fx.Assert(endpointConfigurationName != null, "The endpointConfigurationName parameter must be non null."); TEndpoint retval = default(TEndpoint); bool wildcard = string.Equals(endpointConfigurationName, "*", StringComparison.Ordinal); ClientSection clientSection = ClientSection.GetSection(); foreach (ChannelEndpointElement channelEndpointElement in clientSection.Endpoints) { if (string.IsNullOrEmpty(channelEndpointElement.Kind)) { continue; } if (endpointConfigurationName == channelEndpointElement.Name || wildcard) { TEndpoint endpoint = LookupEndpoint <TEndpoint>(channelEndpointElement); if (endpoint != null) { if (retval != null) { if (wildcard) { throw FxTrace.Exception.AsError( new InvalidOperationException( SR2.DiscoveryConfigMultipleEndpointsMatchWildcard( typeof(TEndpoint).FullName, clientSection.SectionInformation.SectionName))); } else { throw FxTrace.Exception.AsError( new InvalidOperationException( SR2.DiscoveryConfigMultipleEndpointsMatch( typeof(TEndpoint).FullName, endpointConfigurationName, clientSection.SectionInformation.SectionName))); } } else { retval = endpoint; } } } } if (retval == null) { if (wildcard) { throw FxTrace.Exception.AsError( new InvalidOperationException( SR2.DiscoveryConfigNoEndpointsMatchWildcard( typeof(TEndpoint).FullName, clientSection.SectionInformation.SectionName))); } else { throw FxTrace.Exception.AsError( new InvalidOperationException( SR2.DiscoveryConfigNoEndpointsMatch( typeof(TEndpoint).FullName, endpointConfigurationName, clientSection.SectionInformation.SectionName))); } } return(retval); }