title: How to make a C# web service accepts a custom object including unbound elements defined in XSD
body: <p>I'm implementing a C# web service that is supposed to accept a custom message including unbounded number of elements.</p>
  
  <p>Originally, the object is defined in a XSD file like below: </p>
  
  <pre><code>&lt;xsd:element name="LogMessage"&gt;  
  &lt;xsd:complexType&gt;  
  &lt;xsd:sequence&gt;  
  &lt;xsd:element minOccurs="1" maxOccurs="1" name="avantlog" type="tns:LogEventType"&gt;  
  &lt;/xsd:element&gt;  
  &lt;/xsd:sequence&gt;  
  &lt;/xsd:complexType&gt;  
  &lt;/xsd:element&gt;  
  &lt;xsd:complexType name="LogEventType"&gt;  
  &lt;xsd:sequence&gt;  
  &lt;xsd:element minOccurs="1" maxOccurs="1" name="context" type="tns:ContextType"&gt;  
  &lt;/xsd:element&gt;   
  &lt;/xsd:sequence&gt;  
  &lt;/xsd:complexType&gt;  
  &lt;xsd:complexType name="ContextType"&gt;  
  &lt;xsd:sequence&gt;  
  &lt;xsd:element minOccurs="1" maxOccurs="unbounded" name="severity" type="xsd:string"&gt;  
  &lt;/xsd:element&gt;  
  &lt;/xsd:sequence&gt;  
  &lt;/xsd:complexType&gt;  
  </code></pre>
  
  <p>And, in a CS file implementing the web service, I prepared a struct for this:</p>
  
  <pre><code>public struct logevent  
  {  
  public ContextType context;  
  public struct ContextType  
  {  
    public string[] severity;  
  }  
  }  
  </code></pre>
  
  <p>However, when I tried to access an element of the 'serverity' using a line,</p>
  
  <pre><code>String temp = logevent.context.severity.GetValue(0).ToString()  
  </code></pre>
  
  <p>, the program throws a following error:</p>
  
  <pre><code>"Index was outside the bounds of the array."  
  </code></pre>
  
  <p>When I changed the element from 'unbounded' to '1' in the XSD file and also modified 'public string[] severity;' to 'public string severity;', it works. </p>
  
  <p>Can anyone help me to make the web service to accept a message including unbounded numbers of elements?</p>