C# error executing soap client method
I created client from wsdl file using visual studio 2010 Pro, created new project, right click to Reference, choosed "Add Service Reference..." then wrote the address of web service, clicked finished. After Visual Studio generated partial classes, then called method that had two arguments:
CompanyClient client = new CompanyClient(); log logs = client.GetLogs(new System.DateTime(2000, 11, 22), new System.DateTime(2011, 11, 22));
Then have exception:
SystemInvalidException: There was an error reflecting 'arg0'.
System.InvalidOperationException: The top XML element 'arg0' from namespace '' references distinct types System.DateTime and System.Int32. Use XML attributes to specify another XML name or namespace for the element or types.
I wrote soapserver in scala and tested it with SoapUI everything is working, but while developing client such problems occurred.
The issue is that you probably have two arg0 classes (or a variant of that) from two different namespaces (on code side), but serialize as the same root name + namespace on xml side. The SOAP serializer doesn't like this since it cannot figure out whether to deserialize a given type as ns1.arg0 or ns2.arg0 when it sees the xml.
The problem and solution is discussed here: http://social.msdn.microsoft.com/Forums/ar/asmxandxml/thread/e3405d68-9d48-4600-8fa0-1587aa380c47