I am creating a Web Service using ASP.NET C#. I am sending various data types from the webservice so I use the following structure.
public enum WS_ServiceResponseResult
{
    Success,
    Failure,
}
public class WS_ServiceResponse
{
    public WS_ServiceResponseResult result { get; set; }
    public object data { get; set; }
}
public class WS_User
{
    public long id{ get; set; }
    public string name{ get; set; }
}
Webservice Sample Method
    [WebMethod(EnableSession = true)]
    public WS_ServiceResponse LogIn(string username, string pasword)
    {
        WS_ServiceResponse osr = new WS_ServiceResponse();
        long userID = UserController.checkLogin(username, pasword);
        if (userID != 0)
        {
            osr.result = WS_ServiceResponseResult.Success;
            osr.data = new WS_User() { id = userID, name = username };
        }
        else
        {
            osr.result = WS_ServiceResponseResult.Failure;
            osr.data = "Invalid username/password!";
        }
        return osr;
    }
I am using two client types, javascript and C#.NET Windows Form. When I call from javascript I get no problem and the osr.data is filled with WS_User. So i can use osr.data.id easily. But when I use from C#.NET (proxy is generated using "Add Web Reference") I can successfully call but when the result arrives I get a Soap Exception
{System.Web.Services.Protocols.SoapException: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: There was an error generating the XML document. ... ...
What am I missing? I Guess object is not well defined and causing the problems. What are the workarounds?
Thanks
Maksud
Addition:
If add the following dummy method, then it works nicely. Hope it helps, to get the solution.
    [WebMethod]
    public WS_User Dummy()
    {
        return new WS_User();
    }