I need a bit of understanding on how my service contract and the resulting WCF response would affect the client app that would consume my WCF service. Below are the details that I have in my code. Can you help me with the questions below please?
1. In WCF's XML response, how do I change the element
2. In the same output, how do I change
3. Does specifying the XmlElement name attribute ONLY CHANGES THE output display, and not the underlying field/property when this service is consumed by the calling app? I'm checking the output by using the WCF Test Client only and seeing the XML response. Or is the XMLElement name the one to be seen by the calling app?
I've use XMLroot, CollectionsDataContract, and a bunch of other things to put on top of the FinalXmlEntity class to change it's XML element name in the output, but no success. The change in the data members' names have been successful though.
Thank you in advance.
SERVICE INTERFACE:
[ServiceContract]
[XmlSerializerFormat(Style = OperationFormatStyle.Document)]
public interface IService1
{
[OperationContract]
List
}
DATA CONTRACT:
[DataContract]
public class ProgrammeList
{
[DataMember]
public string EmpCode { get; set; }
[XmlElement("Employee Link")]
[DataMember]
public string EmpLink { get; set; }
[DataMember]
public string RoleCode { get; set; }
[XmlArray("EmploymentHistory"), XmlArrayItem("Company")]
[DataMember]
public List
}
RETURNED LIST COLLECTION:
[Serializable]
public class FinalXmlEntity
{
public string EmpCode { get; set; }
[XmlElement("Employee")]
public string EmployeeLink { get; set; }
public string RoleCode { get; set; }
[XmlArray("EmploymentHistory"), XmlArrayItem("Company")]
public List
public FinalXmlEntity(string s1, string s2, string s3, List
{
EmpCode = s1;
EmployeeLink = s2;
RoleCode = s3;
EmploymentLink = ListComp;
}
public FinalXmlEntity()
{
}
}
WCF TEST CLIENT's RESPONSE OUTPUT (in XML tab)
...
...
...
Replies
Know the answer? Post it — somebody with the same question will find it here.