I have a WSDL containing an array of strings. The definition looks like:
<xsd:complexType name="ArrayOfString">
<xsd:sequence>
<xsd:element name="string" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
The full WSDL can be downloaded and checked here: GS1 EPCGlobal 1.0.1 WSDL
After generating the Data Contracts using the svcutil of the Visual Studio 2013 Tools for C# it generated a class, that looks like:
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.33440")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(Namespace = "urn:epcglobal:epcis-query:xsd:1")]
[System.Xml.Serialization.XmlRootAttribute("GetQueryNamesResult", Namespace = "urn:epcglobal:epcis-query:xsd:1", IsNullable = false)]
public partial class ArrayOfString
{
private string[] stringField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("string", Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string[] @string
{
get
{
return this.stringField;
}
set
{
this.stringField = value;
}
}
}
Now when I try to call any operation on the proxy:
var poll = new Poll
{
queryName = "SimpleEventQuery",
@params = new[]
{
new QueryParam {name = "MyParam1", value = "123"},
new QueryParam {name = "MyParam2", value = "Test"},
}
};
try
{
var proxy = new EPCISServiceClient("TEST", "http://thisisthehost:12345/poll");
proxy.ClientCredentials.UserName.UserName = "XXXX";
proxy.ClientCredentials.UserName.Password = "AAAA";
var result = proxy.poll(poll);
Console.WriteLine(result.queryName);
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
I always get an InvalidOperationException:
Unable to generate a temporary class (result=1).
error CS0030: Cannot convert type 'string' to 'ArrayOfString'
error CS0029: Cannot implicitly convert type 'ArrayOfString' to 'string'
Any ideas how to "force" the svcutil to use string[] instead of generating a separate class or any other possibility to fix this?