I am implementing a C # web service that should receive a custom message, including an unlimited number of elements.
Initially, an object is defined in an XSD file, as shown below:
<xsd:element name="LogMessage"> <xsd:complexType> <xsd:sequence> <xsd:element minOccurs="1" maxOccurs="1" name="avantlog" type="tns:LogEventType"> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:complexType name="LogEventType"> <xsd:sequence> <xsd:element minOccurs="1" maxOccurs="1" name="context" type="tns:ContextType"> </xsd:element> </xsd:sequence> </xsd:complexType> <xsd:complexType name="ContextType"> <xsd:sequence> <xsd:element minOccurs="1" maxOccurs="unbounded" name="severity" type="xsd:string"> </xsd:element> </xsd:sequence> </xsd:complexType>
And in the CS file that implements the web service, I prepared the structure for this:
public struct logevent { public ContextType context; public struct ContextType { public string[] severity; } }
However, when I tried to access the "serverity" element using a string,
String temp = logevent.context.severity.GetValue(0).ToString()
The program produces the following error:
"Index was outside the bounds of the array."
When I changed the element from 'unbounded' to '1' in the XSD file, and also changed the 'public string [] severity; for "public line seriousness," it works.
Can someone help me get a web service to accept a message, including an unlimited number of elements?
c # web-services
netgear
source share