Skip to content

Mapping array of struct #2

@DomCotton

Description

@DomCotton

Hi,

I have the following XML-RPC Struct being passed to me.

<?xml version=""1.0"" encoding=""ISO-8859-1""?>
<methodCall>
    <methodName>Vitec.Get_Available_Orders</methodName>
    <params>
        <param>
            <value>
                <struct>
                    <member>
                        <name>OrderID</name>
                        <value>
                            <int>4103100</int>
                        </value>
                    </member>
                    <member>
                        <name>OrderItems</name>
                        <value>
                            <struct>
                                <member>
                                    <name>0</name>
                                    <value>
                                        <struct>
                                            <member>
                                                <name>ItemID</name>
                                                <value>
                                                    <string>809479</string>
                                                </value>
                                            </member>
                                        </struct>
                                    </value>
                                </member>
                <member>
                                    <name>1</name>
                                    <value>
                                        <struct>
                                            <member>
                                                <name>ItemID</name>
                                                <value>
                                                    <string>809479</string>
                                                </value>
                                            </member>
                                        </struct>
                                    </value>
                                </member>
                            </struct>
                        </value>
                    </member>
                </struct>
            </value>
        </param>
    </params>
</methodCall>

I am trying to map this to a C# class but don't know how to handle the OrderItems portion. The issue seems to be the name is an index relating to the item number. I have tried the following:

public class Order
    {
    public int OrderID;

    //public XmlRpcStruct OrderItems;
    public OrderItems OrderItems;
}

OrderItems is a class containing an OrderItem which contains the Item Id. I have tried arrays, arrays of arrays, but no luck. Can you help me understand how to map this? If i bring in the commented line it works but i have to lookup the items by a key value pair. Not ideal but it does work. Just looking for the other way if possible.

Many thanks in advance,
Dominic

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions