Thursday, March 31, 2011

How to Consume Attribute "Description" from webservice

No attribute for Enum values is genereted in client side when code is generated using proxy generator in client side. how can i make them also in client side.

eg

In service or web service

[DataContract] punlic enum Periods { [Description("2 months")] [EnumMember] TwoMonths, }

(or)

[DataContract] punlic enum Periods { [XMLEnum(Value = "2 months")] [EnumMember] TwoMonths, }

but in client side (consumer - consuming web service)

it generates only

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "2.0.50727.1433")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://namespace" + "")] public enum Periods{

    /// <remarks/>
    TwoMonths,

}

how can i access description attribute from web service?

From stackoverflow
  • You can't force this - the mex/WDSL descriptors only contain a tiny subset of the information associated with a type.

    If you control the client, one option is to declare the enum (or even all the types) locally, and consume from there. You should be able to use the svcutil /reference:<path> switch to use types from an existing assembly (the IDE offers the same). But note that this partly breaks the rules of SOA (i.e. you are using more information than the service contract promises).

0 comments:

Post a Comment