Oscar Cabrero
Oscar Cabrero

Reputation: 4169

How to Programatically read the Documentation section of a WSDL in C#

i am using a WSDL file to create a the proxy class file, this service has a big Enumeration. the description for each enum value is in documentation section, how can i programatically read that section?

Upvotes: 1

Views: 1963

Answers (1)

Panos
Panos

Reputation: 19142

A WSDL file is always an XML file, so you can open it and read the elements data. For example, given the eBay Services WSDL file, you can query the documentation of the value COD of the enumeration BuyerPaymentMethodCodeType like this:

    XmlDocument wsdlDoc = new XmlDocument();
    wsdlDoc.Load(@"D:\temp\eBaySvc.wsdl");

    XmlNamespaceManager nsMgr = new XmlNamespaceManager(wsdlDoc.NameTable);
    nsMgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema");

    XmlNode node = wsdlDoc.SelectSingleNode("//xs:simpleType[@name='BuyerPaymentMethodCodeType']/xs:restriction/xs:enumeration[@value='COD']/xs:annotation/xs:documentation", nsMgr);
    string description = node.InnerText;

Upvotes: 4

Related Questions