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'.

Inner exception:

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.

Answers


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

Cheers, Anash


Need Your Help

How can I properly display a null value of type int in a datagrid to users as a string such as “Not specified”?

string silverlight int nullable silverlight-5.0

I have a RadGridView (Telerik) with several columns that represent nullable ints. I have tried using

WCF Intra machine communication - is security necessary?

asp.net wcf security

I'm working on a WCF service that, at least initially, will only be consumed by an ASP.Net application on the same machine. This may change eventually, but for the time being, all communication wit...