tags:

views:

24

answers:

1

Is it valid in XML-RPC to have an unbounded array of elements without having them inside of a array/data parent? From my limited experience with XML-RPC I have seen that arrays should be listed as such:

<member>
   <name>Name</name>
      <value>
         <array>
            <data>
               <value>
                  <string>Red</string>
               </value>
               <value>
                  <string>Blue</string>
               </value>
            </data>
         </array>
       </value>
</member>

...with the parent Name having children strings Red and Blue. However, the 3rd party RPC service we are integrating with sends arrays of unbounded elements without having them inside of the array/data element, but inside a struct, e.g.

<member>
   <name>Name</name>
      <value>
         <struct>
            <member><name>Option0</name>
               <value><string>Red</string>
            </member>
            <member><name>Option1</name>
               <value><string>Blue</string>
            </member>
         </struct>
      </value>
</member>

...With the values of Option1 and Option2 encapsulated inside of a struct.

The problem I am facing is that when designing the classes that will be serialized, I would have to design my class such as

private string Option0
private string Option1

...

...instead of:

private string[] Name

As I do not know the number of unbounded fields coming back in the structure, it seems the right way to accomplish the task would be to have an array of strings to enumerate through. However, there are no arrays in the resoponse XML, just structures with a dynamic number of fields. Because of that, I would have to list a large number of fields to conform to the structure, even though it's not really a structure, but an array. Is there something I am missing with the XML-RPC?

+2  A: 

Yes it is quite valid XML-RPC struct. We also have such case and are using Cook Computings' XML-RPC.NET. It works perfectly. Check it, there is a special class there called XmlRpcStruct. You just need to use it in your XML-RPC method request or response.

Incognito