XmlSchema GetSchema(string ns) { ICollection colln = GeneratedXmlSchemas.Schemas(ns); if (colln.Count > 0) { if (colln.Count > 1) { throw new Exception("More than 1 schema found for ns = " + ns); } //FIXME: HORRIBLE! foreach (object o in colln) { return(o as XmlSchema); } } XmlSchema schema = new XmlSchema(); schema.TargetNamespace = ns; schema.ElementFormDefault = XmlSchemaForm.Qualified; GeneratedXmlSchemas.Add(schema); return(schema); }
public override MetadataSet GetGeneratedMetadata() { if (metadata != null) { return(metadata); } metadata = new MetadataSet(); foreach (WSServiceDescription sd in GeneratedWsdlDocuments) { metadata.MetadataSections.Add( MetadataSection.CreateFromServiceDescription(sd)); } foreach (XmlSchema xs in GeneratedXmlSchemas.Schemas()) { if (xs.TargetNamespace != XmlSchema.Namespace) { metadata.MetadataSections.Add( MetadataSection.CreateFromSchema(xs)); } } return(metadata); }
ContractExportMap ExportContractInternal(ContractDescription contract) { if (ExportedContracts.ContainsKey(contract)) { return(ExportedContracts [contract]); } QName qname = new QName(contract.Name, contract.Namespace); if (ExportedContracts.Any(m => m.Value.QName == qname)) { throw new ArgumentException(String.Format( "A ContractDescription with Namespace : {0} and Name : {1} has already been exported.", contract.Namespace, contract.Name)); } WSServiceDescription sd = GetServiceDescription(contract.Namespace); List <IWsdlExportExtension> extensions = new List <IWsdlExportExtension> (); foreach (IWsdlExportExtension extn in contract.Behaviors.FindAll <IWsdlExportExtension> ()) { extensions.Add(extn); } XmlDocument xdoc = new XmlDocument(); PortType ws_port = new PortType(); ws_port.Name = contract.Name; foreach (OperationDescription sm_op in contract.Operations) { Operation ws_op = new Operation(); ws_op.Name = sm_op.Name; foreach (MessageDescription sm_md in sm_op.Messages) { //OperationMessage OperationMessage ws_opmsg; WSMessage ws_msg = new WSMessage(); MessagePart ws_msgpart; if (sm_md.Direction == MessageDirection.Input) { ws_opmsg = new OperationInput(); ws_msg.Name = String.Concat(ws_port.Name, "_", ws_op.Name, "_", "InputMessage"); ws_msgpart = ExportMessageBodyDescription(sm_md.Body, ws_op.Name, sd.TargetNamespace); } else { ws_opmsg = new OperationOutput(); ws_msg.Name = String.Concat(ws_port.Name, "_", ws_op.Name, "_", "OutputMessage"); ws_msgpart = ExportMessageBodyDescription(sm_md.Body, ws_op.Name + "Response", sd.TargetNamespace); } ws_msg.Parts.Add(ws_msgpart); /* FIXME: Faults */ //Action XmlAttribute attr = xdoc.CreateAttribute("wsaw", "Action", "http://www.w3.org/2006/05/addressing/wsdl"); attr.Value = sm_md.Action; ws_opmsg.ExtensibleAttributes = new XmlAttribute [] { attr }; //FIXME: Set .Input & .Output ws_opmsg.Message = new QName(ws_msg.Name, sd.TargetNamespace); ws_op.Messages.Add(ws_opmsg); sd.Messages.Add(ws_msg); } ws_port.Operations.Add(ws_op); foreach (IWsdlExportExtension extn in sm_op.Behaviors.FindAll <IWsdlExportExtension> ()) { extensions.Add(extn); } } //Add Imports for <types XmlSchema xs_import = new XmlSchema(); xs_import.TargetNamespace = String.Concat( contract.Namespace, contract.Namespace.EndsWith("/") ? "" : "/", "Imports"); foreach (XmlSchema schema in GeneratedXmlSchemas.Schemas()) { XmlSchemaImport imp = new XmlSchemaImport(); imp.Namespace = schema.TargetNamespace; xs_import.Includes.Add(imp); } sd.Types.Schemas.Add(xs_import); sd.PortTypes.Add(ws_port); var map = new ContractExportMap(qname, contract, extensions); ExportedContracts.Add(contract, map); WsdlContractConversionContext context = new WsdlContractConversionContext(contract, ws_port); foreach (IWsdlExportExtension extn in extensions) { extn.ExportContract(this, context); } return(map); }