Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to specify a sequence of elements instead of an array of elements in a .NET WCF Web Service?
    text
    copied!<p>I have a .NET 4 WCF web service which takes a data contract with an optional enumerable of strings. For example:</p> <p>Service Code:</p> <pre><code>[DataMember(IsRequired = true)] public string Something { get { return _Something; } set { _Something= value; } } private string _Something; [DataMember(IsRequired = false)] public string[] MoreThings { get { return _MoreThings.ToArray&lt;string&gt;(); } set { _MoreThings = new List&lt;string&gt;(value); } } private List&lt;string&gt; _MoreThings = new List&lt;string&gt;(); </code></pre> <p>WSDL:</p> <pre><code> &lt;xsd:complexType name="MyDataContract"&gt; &lt;xsd:sequence&gt; &lt;xsd:element minOccurs="1" name="Something" type="xsd:string" /&gt; &lt;xsd:element minOccurs="0" name="MoreThings" nillable="true" type="q1:ArrayOfstring" xmlns:q1="http://schemas.microsoft.com/2003/10/Serialization/Arrays" /&gt; &lt;/xsd:sequence&gt; &lt;/xsd:complexType&gt; </code></pre> <p>I'm trying to interface with the service from a number of different platforms, but one is Perl using SOAP::WSDL (and wsdl2perl.pl in particular), which seems to be failing on recognizing "ArrayOfstring". Is there anything I can do in my code so that the WSDL would read like this:</p> <pre><code> &lt;xsd:complexType name="MyDataContract"&gt; &lt;xsd:sequence&gt; &lt;xsd:element minOccurs="1" name="Something" type="xsd:string" /&gt; &lt;xsd:element minOccurs="0" maxOccurs="unbounded" name="MoreThings" nillable="true" type="xsd:string" /&gt; &lt;/xsd:sequence&gt; &lt;/xsd:complexType&gt; </code></pre> <p>I'm open to other suggestions, as well. Basically, I'm trying to do something similar to declaring a method MyOperation(string something, params string[] moreThings), where any number of additional moreThings parameters may be passed, but in a way that doesn't cause interop issues with non-.NET platforms.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload