void NoExtensionsSetup() { XmlReaderSettings xs = new XmlReaderSettings(); xs.IgnoreWhitespace = true; xtr = XmlTextReader.Create("Test/System.ServiceModel.Description/dump.xml", xs); xtr.Read(); //FIXME: skipping Headers while (xtr.LocalName != "Body") { if (!xtr.Read()) { return; } } //Move to <Metadata .. xtr.Read(); ms = MetadataSet.ReadFrom(xtr); //MyWsdlImportExtension mw = new MyWsdlImportExtension (); List <IWsdlImportExtension> list = new List <IWsdlImportExtension> (); //list.Add (mw); list.Add(new DataContractSerializerMessageContractImporter()); /*list.Add (new MessageEncodingBindingElementImporter ()); * list.Add (new TransportBindingElementImporter ()); * list.Add (new StandardBindingImporter ());*/ wi = new WsdlImporter(ms, null, list); }
public void Setup() { XmlReader xr = XmlTextReader.Create("Test/System.Runtime.Serialization/one.xml"); metadata = MetadataSet.ReadFrom(xr); NewXmlSchemaSet(); }
public void Setup() { XmlReader xr = XmlTextReader.Create(TestResourceHelper.GetFullPathOfResource("Test/Resources/one.xml")); metadata = MetadataSet.ReadFrom(xr); NewXmlSchemaSet(); }
internal static Binding GetBindingFromMetadata(EndpointDiscoveryMetadata metadata) { var metadataExtension = (from extension in metadata.Extensions where extension.Name == WcfConstants.EndpointMetadata select extension).FirstOrDefault(); if (metadataExtension == null) { return(null); } var endpointMetadata = metadataExtension.Elements().FirstOrDefault(); if (endpointMetadata == null) { return(null); } using (var xmlReader = endpointMetadata.CreateReader()) { var metadataSet = MetadataSet.ReadFrom(xmlReader); var importer = new WsdlImporter(metadataSet); var endpoints = importer.ImportAllEndpoints(); if (endpoints.Count > 0) { return(endpoints[0].Binding); } } return(null); }
internal static MetadataSet LoadMetadataFromString(string doc) { var buffer = Encoding.UTF8.GetBytes(doc); using (var ms = new MemoryStream(buffer)) { var reader = new XmlTextReader(ms); return(MetadataSet.ReadFrom(reader)); } }
public void ReadFrom() { XmlReader xr = XmlTextReader.Create(TestResourceHelper.GetFullPathOfResource("Test/Resources/one.xml")); var metadata = MetadataSet.ReadFrom(xr); Assert.AreEqual(5, metadata.MetadataSections.Count, "#1"); Assert.AreEqual(2, metadata.MetadataSections.Where(m => m.Dialect == MetadataSection.ServiceDescriptionDialect).Count(), "#2"); Assert.AreEqual(3, metadata.MetadataSections.Where(m => m.Dialect == MetadataSection.XmlSchemaDialect).Count(), "#3"); }
public void ExtensionsTest() { XmlReaderSettings xs = new XmlReaderSettings(); xs.IgnoreWhitespace = true; xtr = XmlTextReader.Create("Test/System.ServiceModel.Description/dump.xml", xs); xtr.Read(); //FIXME: skipping Headers while (xtr.LocalName != "Body") { if (!xtr.Read()) { return; } } //Move to <Metadata .. xtr.Read(); ms = MetadataSet.ReadFrom(xtr); Assert.AreEqual(typeof(WSServiceDescription), ms.MetadataSections [0].Metadata.GetType(), "#ET1"); WSServiceDescription wsd = ms.MetadataSections [1].Metadata as WSServiceDescription; //ServiceDescription Assert.IsNotNull(wsd.Extensions, "#ET2"); Assert.AreEqual(0, wsd.Extensions.Count, "#ET3"); //Binding [0] Assert.IsNotNull(wsd.Bindings [0].Extensions, "#ET4"); Assert.AreEqual(1, wsd.Bindings [0].Extensions.Count, "#ET5"); Assert.AreEqual(typeof(SoapBinding), wsd.Bindings [0].Extensions [0].GetType(), "#ET6"); //Binding [0].Operations [0] Assert.IsNotNull(wsd.Bindings [0].Operations [0].Extensions, "#ET7"); Assert.AreEqual(1, wsd.Bindings [0].Operations [0].Extensions.Count, "#ET8"); Assert.AreEqual(typeof(SoapOperationBinding), wsd.Bindings [0].Operations [0].Extensions [0].GetType(), "#ET9"); //Binding [0].Operations [1] Assert.IsNotNull(wsd.Bindings [0].Operations [1].Extensions, "#ET10"); Assert.AreEqual(1, wsd.Bindings [0].Operations [1].Extensions.Count, "#ET11"); Assert.AreEqual(typeof(SoapOperationBinding), wsd.Bindings [0].Operations [1].Extensions [0].GetType(), "#ET12"); //Service.Port Assert.IsNotNull(wsd.Services [0].Ports [0].Extensions, "#ET13"); Assert.AreEqual(1, wsd.Services [0].Ports [0].Extensions.Count, "#ET14"); Assert.AreEqual(typeof(SoapAddressBinding), wsd.Services [0].Ports [0].Extensions [0].GetType(), "#ET15"); }
public static MetadataSet LoadMetadataFromFile(string name) { var asm = Assembly.GetExecutingAssembly(); if (!name.EndsWith(".xml")) { name = name + ".xml"; } var filename = TestResourceHelper.GetFullPathOfResource("Test/MetadataTests/Resources/" + name); using (var stream = new StreamReader(filename)) { var reader = new XmlTextReader(stream); return(MetadataSet.ReadFrom(reader)); } }
public static MetadataSet LoadMetadataFromResource(string name) { var asm = Assembly.GetExecutingAssembly(); if (!name.EndsWith(".xml")) { name = name + ".xml"; } var resname = "MetadataTests.Resources." + name; using (var stream = asm.GetManifestResourceStream(resname)) { if (stream == null) { throw new InvalidOperationException( "No such resource: " + name); } var reader = new XmlTextReader(stream); return(MetadataSet.ReadFrom(reader)); } }
public static MetadataSet LoadMetadataFromFile(string name) { var asm = Assembly.GetExecutingAssembly(); if (!name.EndsWith(".xml")) { name = name + ".xml"; } var uri = new Uri(asm.CodeBase); var path = Path.GetDirectoryName(uri.AbsolutePath); path = Path.Combine(path, "Test"); path = Path.Combine(path, "MetadataTests"); path = Path.Combine(path, "Resources"); var filename = Path.Combine(path, name); using (var stream = new StreamReader(filename)) { var reader = new XmlTextReader(stream); return(MetadataSet.ReadFrom(reader)); } }
public XmlSchemaSet Get() { Message getRequest = Message.CreateMessage(MessageVersion.Default, Constants.WsTransfer.GetAction); Message getResponse = Get(getRequest); MetadataSet set = MetadataSet.ReadFrom(getResponse.GetReaderAtBodyContents()); XmlSchemaSet schemaSet = new XmlSchemaSet(); foreach (MetadataSection section in set.MetadataSections) { if (section.Dialect.Equals(Constants.Xsd.Namespace) && section.Identifier.Equals(":")) { XmlSchema schema = section.Metadata as System.Xml.Schema.XmlSchema; if (schema != null) { schemaSet.Add(schema); } } } schemaSet.Compile(); return(schemaSet); }
/// <summary> /// Gets the schema from an embedded resource. /// </summary> /// <returns></returns> private static XmlSchemaSet GetSchema() { Stream schemaStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(SchemaResourceName); XmlTextReader xmlTextReader = new XmlTextReader(schemaStream); // create the XmlSchemaSet MetadataSet set = MetadataSet.ReadFrom(xmlTextReader); XmlSchemaSet schemaSet = new XmlSchemaSet(); foreach (MetadataSection section in set.MetadataSections) { if (section.Dialect.Equals(SchemaDialect) && section.Identifier.Equals(":")) { XmlSchema schema = section.Metadata as System.Xml.Schema.XmlSchema; if (schema != null) { schemaSet.Add(schema); } } } schemaSet.Compile(); return(schemaSet); }
public static MetadataSet LoadMetadataFromFile(string name) { var asm = Assembly.GetExecutingAssembly(); if (!name.EndsWith(".xml")) { name = name + ".xml"; } var uri = new Uri(asm.CodeBase); // Run from mcs/class/lib/<profile> var path = Path.GetDirectoryName(uri.AbsolutePath); path = Directory.GetParent(path).Parent.Parent.FullName; path = Path.Combine(path, "System.ServiceModel"); path = Path.Combine(path, "Test"); path = Path.Combine(path, "MetadataTests"); path = Path.Combine(path, "Resources"); var filename = Path.Combine(path, name); using (var stream = new StreamReader(filename)) { var reader = new XmlTextReader(stream); return(MetadataSet.ReadFrom(reader)); } }
public void ReadFromNull() { MetadataSet.ReadFrom(null); }