public void ShouldGetMetadataFromWsdlFile() { string wsdlLocation = ConfigurationLoader.GetConfigurationFilePath(@"SampleData\DescriptionModel\MockService.wsdl"); MetadataDiscovery instance = new MetadataDiscovery(wsdlLocation); MetadataSet metadata = instance.InspectMetadata(); AssertMetadataForWsdlFile(metadata); }
public void ShouldFailWithNoMexEndpoint() { using (ServiceHost host = CreateBasicHttpHost(Address, false, true)) { MetadataDiscovery instance = new MetadataDiscovery(Address); MetadataSet metadata = instance.InspectMetadata(); } }
public void ThrowOnBasicHttpHostSslMexAddress() { using (ServiceHost host = CreateBasicHttpHost(Address)) { MetadataDiscovery instance = new MetadataDiscovery(SslMexAddress); instance.InspectMetadata(); } }
public void ShouldGetMetadataFromBasicHttpHostWsdlAddressWithNoGet() { using (ServiceHost host = CreateBasicHttpHost(Address, false, false)) { MetadataDiscovery instance = new MetadataDiscovery(WsdlAddress); MetadataSet metadata = instance.InspectMetadata(); AssertMetadataForBasicHttp(metadata); } }
public void ShouldGetWritenMetadataDocumentsToFiles() { string wsdlLocation = ConfigurationLoader.GetConfigurationFilePath(@"SampleData\DescriptionModel\MockService.wsdl"); MetadataDiscovery instance = new MetadataDiscovery(wsdlLocation); string mapFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory + @"\Test\", "MockService.map"); DiscoveryClientResultCollection results = instance.WriteMetadata(mapFile); Assert.AreEqual <int>(4, results.Count); }
/// <summary> /// Creates the WSDL importer. /// </summary> /// <param name="wsdlFile">The WSDL file.</param> /// <returns></returns> public static WsdlImporter CreateImporter(string wsdlFile) { MetadataDiscovery discovery = new MetadataDiscovery(ConfigurationLoader.GetConfigurationFilePath(wsdlFile)); ContractGenerator generator = CreateContractGenerator(); WsdlImporter importer = generator.CreateWsdlImporter(discovery.InspectMetadata()); importer.ImportAllEndpoints(); importer.ImportAllContracts(); importer.ImportAllBindings(); ContractGenerator.ThrowOnMetadataConversionErrors(importer.Errors); return(importer); }
public void Import(ICodeWriter codeWriter) { var dataContractGenerationExtensions = new List <IXsdImportExtension> { new TypeRenameExtension(TypeRenameMappings), new RemoveExtraDataContractNameExtension(), new TypeAccessModifierExtension(TypeAccessModifiers), new RemoveServiceContractConfigurationNameExtension(), new IsRequiredMemberOverrideExtension(RequiredMemberOverrides), new ReplaceArrayOfTWithListTExtension() }; var codeCompileUnit = new CodeCompileUnit(); var codeProvider = CreateCodeProvider(); var discovery = new MetadataDiscovery(); var metadataSections = new List <MetadataSection>(); foreach (var wsdl in Wsdls) { var metadataSet = discovery.Discover(wsdl); metadataSections.AddRange(metadataSet.MetadataSections); } var xsdDataContractImporter = new XsdDataContractImporterFactory().Create(codeProvider, codeCompileUnit, NamespaceMappings); var wsdlImporter = new WsdlImporterFactory().Create(new MetadataSet(metadataSections), xsdDataContractImporter, NillableOverrides, XmlTypeMappings, DataContractGenerationOptions); var serviceContractGenerator = CreateServiceContractGenerator(codeCompileUnit, NamespaceMappings, ServiceContractGenerationOptions); wsdlImporter.ImportAllBindings(); wsdlImporter.ImportAllEndpoints(); foreach (var contract in wsdlImporter.ImportAllContracts()) { serviceContractGenerator.GenerateServiceContractType(contract); } foreach (var dataContractGenerationExtension in dataContractGenerationExtensions) { dataContractGenerationExtension.GenerateContract(codeCompileUnit); } codeWriter.Write(codeProvider, codeCompileUnit); }
private MetadataSet GetMetadataSet(Uri address, Type service, Type serviceContract, Type secondaryServiceContract) { MetadataDiscovery metadata = new MetadataDiscovery(address); if (!address.IsFile) { using (ServiceHost host = CreateWsHttpHost(address, service, serviceContract, secondaryServiceContract)) { return(metadata.InspectMetadata()); } } return(metadata.InspectMetadata()); }
private ServiceModel CreateServiceModel() { var discovery = new MetadataDiscovery(); var metadataSections = new List <MetadataSection>(); foreach (var xsd in Xsds) { var metadataSet = discovery.Discover(xsd); metadataSections.AddRange(metadataSet.MetadataSections); } var schemaSet = CreateXmlSchemaSet(metadataSections); return(new ServiceModel { XmlSchemas = schemaSet }); }
public void ShouldGetMetadataFromBasicHttpHostAsync() { using (ServiceHost host = CreateBasicHttpHost(Address)) { AutoResetEvent reset = new AutoResetEvent(false); MetadataDiscovery instance = new MetadataDiscovery(Address); instance.InspectMetadataCompleted += delegate(object sender, InspectMetadataCompletedEventArgs e) { try { Assert.IsNull(e.Exception); AssertMetadataForBasicHttp(e.Metadata); } finally { reset.Set(); } }; instance.InspectMetadataAsync(); reset.WaitOne(100000, true); } }
public void ThrowOnFileNotFound() { MetadataDiscovery discovery = new MetadataDiscovery(@"c:\foo"); discovery.InspectMetadata(); }
public void CanCreateInstance() { MetadataDiscovery instance = new MetadataDiscovery(Address); Assert.AreEqual(Address, instance.Address); }
public void ThrowOnNoValidSslAddress() { MetadataDiscovery instance = new MetadataDiscovery(SslAddress); instance.InspectMetadata(); }