Podívejme se na příklad:
Vytvoříme si nový ServiceContract.
[ServiceContract] public interface IEventService { [OperationContract] [WebGet(UriTemplate = "EventInfo/{exe_name}", ResponseFormat = WebMessageFormat.Xml)] EventInfo GetEventInfo(string exe_name); }
[OperationContract] [WebInvoke(Method = "PUT", UriTemplate = "/customer/{id}")] public void PutCustomer(int id, Customer customer) { } [OperationContract] [WebInvoke(Method = "DELETE", UriTemplate = "/customer/{id}")] public void DeleteCustomer(int id) { }
[DataContract] public class EventInfo { [DataMember] public string Name { get; set; } }
<EventInfo> <Name>AKCE</Name> </EventInfo>
[DataContract(Name="MyEventInfo")] public class EventInfo { [DataMember(Name="Jmeno")] public string Name { get; set; } }
Pokud do atributu DataContract přidáte parametr Name, dostane tag ve výstupním XML toto jméno. To samé se stane, když přidáte parametr Name do atributu DataMember.Ze serveru se mi vrátí XML:
<MyEventInfo xmlns="http://schemas.datacontract.org/2004/07/WCF8bcPgServices" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <Jmeno>AKCE</Jmeno> </MyEventInfo>
Žádné komentáře:
Okomentovat