Sebastian Loer

Sebastian Loer

  • NA
  • 10
  • 1.4k

Serialization of an Array in a SOAP message

Feb 11 2022 7:04 AM

Hey guys,

i have a problem with the serialization of an array during a SOAP request:

The interesting part of the incoming Message looks like this:

<wait4get>
    <userName>test</userName>
    <passWord>test</passWord>
    <watchdog>
        <clientId>test</clientId>
        <timeOut>30</timeOut>
    </watchdog>
    <get>
        <userName>test</userName>
        <passWord>test</passWord>
        <watchdog/>
        <objectType>TestData</objectType>
        <filterList>
        <filter>
            <identifier>
                <ident>testident</ident>
            </identifier>
            </filter>
        </filterList>
        <position>11</position>
    </get>
</wait4get>

The class of my source code looks like this:

public class wait4GetType : headerRequest
{
    [XmlElement("get")] public getType[] get { get; set; }

    [XmlAttribute] public int maxWaitTime { get; set; }

    [XmlIgnore] public bool maxWaitTimeSpecified { get; set; }

    public override string AddToString(int indent)
    {
        var s = base.AddToString(indent);
        indent++;
        AddToString(indent, ref s, "get", get);
        AddToString(indent, ref s, "maxWaitTime", maxWaitTime);
        AddToString(indent, ref s, "maxWaitTimeSpecified", maxWaitTimeSpecified);
        return s;
    }
}

The problem is that my process expects an extra node <getType> like in the following example:

<get>

<getType>

.....

</getType>

<get>

Without this extra node, the element <get> is an empty array after the serialization.

How can i change this behaviour?

Best Regards


Answers (3)