[Serializable()]
public class MyClass
{
protected string m_stName;
protected string m_stCode;
protected int m_iId;
public MyClass() {}
public string Name { /* get and set */ }
public string Code { /* get and set */ }
public int Id { /* get and set */ }
}
And a simple web service project with one web method -
[WebMethod]
public MyClass MyClass()
{
MyClass retVal = new MyClass();
retVal.Name = "My Class";
retVal.Id = 0;
retVal.Code = "MC 0";
return retVal;
}
When I try debugging (simple debug using ie as client in VS, maybe that is
the problem?), I get...
A first chance exception of type 'System.InvalidOperationException' occurred
in system.xml.dll
Additional information: The XML element named 'MyClass' from namespace
'http://tempuri.org/' references a method and a type. Change the method's
message name using WebMethodAttribute or change the type's root element
using the XmlRootAttribute.
<<
If I change the web method name to "getClass" so it isn't the same name as
the return type, I get...
A first chance exception of type 'System.ArgumentException' occurred in
mscorlib.dll
Additional information: Error binding to target method.
<<
Anyone have a link to a good example of returning a custom class with web
services? Been googling, haven't found one yet.
Thanks in advance!
Derrick