Here are some resources in relation to WCF Service routing:
- MSDN Routing Feature Overview
- Building a Service Router Part 1 - MSDN Magazine (Michelle Leroux Bustamante)
- Building a Service Router Part 2 - MSDN Magazine (Michelle Leroux Bustamante)
namespace XmlValidator { using System; using System.IO; using System.Linq; using System.Xml; using System.Xml.Linq; using System.Xml.Schema; public class EasyXmlValidator { private Action<string> output; public EasyXmlValidator(Action<string> outputWriter) { this.output = outputWriter; } public bool Verify(string[] schemaFilenames, string xml) { var schemaSet = new XmlSchemaSet(); foreach (string schema in schemaFilenames) { string content = File.ReadAllText(schema); XDocument document = XDocument.Parse(content); var namespaceElement = document.Root.Attributes("targetNamespace").FirstOrDefault(); var name = namespaceElement == null ? string.Empty : namespaceElement.Value; schemaSet.Add(name, XmlReader.Create(new StringReader(content))); } XDocument doc1 = XDocument.Parse(xml); Console.WriteLine("Validating doc1"); bool errors = false; doc1.Validate(schemaSet, (o, e) => { this.output(string.Format("{0}", e.Message)); errors = true; }); this.output(string.Format("doc1 {0}", errors ? "did not validate" : "validated")); return !errors; } public bool Verify(string schema, string xml) { return Verify(new[] { schema }, xml); } } }
<xsd:schema targetNamespace="http://wcf.rees.biz/CalculatorDemo/2011/06/Imports">
<xsd:import schemaLocation="http://localhost:55401/CalculatorService.svc?xsd=xsd0" namespace="http://wcf.rees.biz/CalculatorDemo/2011/06" />
<xsd:import schemaLocation="http://localhost:55401/CalculatorService.svc?xsd=xsd1" namespace="http://schemas.microsoft.com/2003/10/Serialization/" />
<xsd:import schemaLocation="http://localhost:55401/CalculatorService.svc?xsd=xsd2" namespace="http://wcf.rees.biz/CalculatorDemo/2011/06/" />
</xsd:schema>
</wsdl:types>