Question

How can I add a custom section to WSDL that's directly under wsdl:definitions? Something like this: Custom WSDL section I've tried stuff like using custom attributes that implement IWsdlExportExtension, but I havent gotten even close to the result I need and I'm not sure if that's the right way to do this. Is that even possible or should I just paste that section into file and specify externalMetadataLocation in web.config?

Was it helpful?

Solution

The wsdl from your question has been genereted from asmx. If you want to do the same you should use IVIS library and decorate your class with ISService attrubute. For WCF you should do next:

        [CustomAttribute]
        public class Service1 : IService1
        {
           public void DoWork()
           {
           }
        }
     public class CustomAttribute:Attribute,  System.ServiceModel.Description.IWsdlExportExtension, System.ServiceModel.Description.IWsdlImportExtension, IContractBehavior
   {
            public void ExportContract(System.ServiceModel.Description.WsdlExporter exporter, System.ServiceModel.Description.WsdlContractConversionContext context)
        {
        BeforeImport(exporter.GeneratedWsdlDocuments, exporter.GeneratedXmlSchemas, new  List<XmlElement>());
        }
     public void  BeforeImport(System.Web.Services.Description.ServiceDescriptionCollection wsdlDocuments, System.Xml.Schema.XmlSchemaSet xmlSchemas, ICollection<XmlElement> policy)
     {
    //throw new NotImplementedException();

        var xdoc = new XmlDocument();
        var element = xdoc.CreateElement("ivis","WebServiceInfo", "ivis");
        var node = xdoc.CreateNode(XmlNodeType.Element, "Identifier", "ivis");
        node.InnerText = "URN:IVIS:100001:ISS-IeM";
        element.AppendChild(node);
        /// and so on :)
        wsdlDocuments[0].Extensions.Add(element);

     }
}

Body of all others methods for implemented interfaces can be empty. This is in first approach.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top