2

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?

moik
  • 165
  • 5
  • 14
  • can you post complete WSDL? – Viru Feb 04 '16 at 09:48
  • @Viru: http://www.gs1.org/epcis/epcis_1_0-schema-20070412 – moik Feb 04 '16 at 09:51
  • This takes me to a webpage? – Viru Feb 04 '16 at 09:58
  • @Viru: Yes there you can get the WSDL and the respective XSD schemas – moik Feb 04 '16 at 09:58
  • @moik - Please post the code you use to call the method from the client. – Tim Feb 04 '16 at 16:29
  • @Tim - sorry for the late response. I have added the client code now! – moik Feb 08 '16 at 08:44
  • For me this was due to a mismatch between the EPCIS WSDL and its referred XSDs. The service was using a slightly modified WSDL (different xsd imports) and two of those xsd's had a circular reference to each other. This cause SoapUI and SvcUtil (and vs) to not generate the complete code, but the MS stuff seems to have failed silently while soapUI at least had a cryptic message in the error log. – StingyJack Oct 28 '16 at 13:35

0 Answers0