Change element names

1

I would like to clarify some doubts since I do not have much experience with Web-Services and, currently, I was in charge of reviewing and implementing some changes in an already implemented system. Through inexperience, I am facing basic difficulties in understanding and modifying certain passages of the code given to me.

The problem : I need to properly map the response elements for a particular operation. The response object consists of the following elements:

<operacaoResponse xmlns="namespace">
    <sucesso xmlns="namespace"></sucesso>
    <mensagem xmlns="namespace"></mensagem>
    <documento xmlns="namespace">
                                 ...</documento>
</operacaoResponse>

where <documento> is a complex element.

The class that implements this object is encoded as follows:

    [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    [System.ServiceModel.MessageContractAttribute(WrapperName="operacaoResponse", WrapperNamespace="namespace", IsWrapped=true)]
    public partial class operacaoResponse {

    [System.ServiceModel.MessageBodyMemberAttribute(Namespace="namespace", Order=0)]
    [System.Xml.Serialization.XmlElementAttribute(Namespace="namespace")]
    public bool sucesso;

    [System.ServiceModel.MessageBodyMemberAttribute(Namespace="namespace", Order=1)]
    [System.Xml.Serialization.XmlElementAttribute(Namespace="namespace")]
    public string mensagem;

    [System.ServiceModel.MessageBodyMemberAttribute(Namespace="namespace", Order=2)]
    [System.Xml.Serialization.XmlElementAttribute(Namespace="namespace")]
    public Package.tipoDocumento documento;

The document object should be formatted as follows:

<documento>
    <a></a>
    <b></b>
    <c></c>
</documento>

And the class "DocumentDocument" is implemented as follows:

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml", "4.0.30319.34234")]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace="namespace")]
public partial class tipoDocumento {

    private tipoA aField;

    private tipoB[] bField;

    private tipoC[] cField;

    /// <remarks/>
    public tipoA aField {
        get {
            return this.aField;
        }
        set {
            this.aField = value;
        }
    }
...

My question is : how do you make the property aField mapable by following the xml pattern described above? I am referring to the nomenclature of the elements. Even when I specify an XmlElement to the property and define a new ElementName the information is generated following the original naming of the property.

    [System.Xml.Serialization.XmlElementAttribute(ElementName="a", Order="0")
    public tipoA aField {
        get {
            return this.aField;
        }
        set {
            this.aField = value;
        }
    }
    
asked by anonymous 25.11.2015 / 22:20

0 answers