public static Wsdl Parse(string filename) { XmlDocument doc = new XmlDocument(); doc.Load(filename); XmlNamespaceManager ns = new XmlNamespaceManager(doc.NameTable); ns.AddNamespace("wsdl", "http://schemas.xmlsoap.org/wsdl/"); ns.AddNamespace("wsdlsoap", "http://schemas.xmlsoap.org/wsdl/soap/"); Wsdl model = new Wsdl(); model.TargetNamespace = GetSingleNodeInnerText( doc, ns, "/wsdl:definitions/@targetNamespace"); ns.AddNamespace("tns", model.TargetNamespace); ns.AddNamespace("schema", model.TargetNamespace); model.PortTypeName = GetSingleNodeInnerText( doc, ns, "/wsdl:definitions/wsdl:portType/@name"); model.PortTypeNameVariable = model.PortTypeName.Replace(".", ""); XmlNodeList operationList = doc.SelectNodes( "/wsdl:definitions/wsdl:binding/wsdl:operation", ns); foreach (XmlNode operation in operationList) { WsdlOperation op = new WsdlOperation(); op.Name = GetSingleNodeInnerText(operation, ns, "@name"); op.Action = GetSingleNodeInnerText(operation, ns, "./wsdlsoap:operation/@soapAction"); op.Input = GetWsdlParameter(operation, ns, WsdlParameterType.input); op.Output = GetWsdlParameter(operation, ns, WsdlParameterType.output); model.Operations.Add(op); } return(model); }
static void Main(string[] args) { /* * if (args.Length != 2) * { * PrintUsage(); * return; * } */ string inWsdl = @"OE2.Service.ProductOffering.wsdl"; // args[0]; string outCSharp = @"test.cs"; // args[1]; Model.Wsdl model = Model.WsdlParser.Parse(inWsdl); Console.WriteLine(Template.Generator.Generate(model, "TestNs.Data", "TestNs.Msgs")); }