2

I have a web-method called GetSessionData() returning a SessionData object so defined:

public class SessionData
{
    private SalesDataDAO _dao;

    public SessionData()
    {
        this._dao = new SalesDataDAO();
        SessionId = 0;
    }

    public int SessionId { get; set}

    public string UserId { get; set}

    public string UserName { get; set}

    public string Group { get; set}

    // ...

    public SalesData GetSalesData()
    {
        SalesData sd = null;

        if (SessionId > 0)
        {
            sd = _dao.GetSalesData(SessionId);
        }

        return sd;
    }
}

Calling the GetSessionData method from the client I get a proxy object having only public properties.

Is there a way to use the SessionData object as if I was working with a local object? How could I structure my object to obtain data from the WS in a transparent way?

NOTE #1 I'm not using WCF.

NOTE #2 The main issue is not to share the same type both on server and client side. What I'm just trying to achieve is retrieving the data from the server by GetSalesData() method. Actually this method should do some kind of remote call... Is there a way to obtain this? WCF is the right technology to solve this issue? I'm not an expert of RPC...

davioooh
  • 23,742
  • 39
  • 159
  • 250
  • possible duplicate: http://stackoverflow.com/questions/216884/force-net-webservice-to-use-local-object-class-not-proxy-class#216924 – dknaack Jan 25 '12 at 09:08
  • 1
    is this using WCF? or 2.0-style web services? With the latter: you can't (conveniently) – Marc Gravell Jan 25 '12 at 09:08
  • @MarcGravell I'm using classical web service, not WCF... – davioooh Jan 25 '12 at 09:14
  • 1
    so I suppose I need to find another way to solve my problem... I think I'll extract the `GetSalesData` from my class and set it as a new web method in my service... – davioooh Jan 25 '12 at 10:36
  • ASMX does not support this. One of many reasons to move to WCF. – John Saunders Jan 25 '12 at 12:25
  • @JohnSaunders can you please suggest me some helpful example or reference (about WCF) that address my specific issue? – davioooh Jan 27 '12 at 11:49
  • When you use "Add Service Reference" to create a proxy, you can check a box that says to reuse the types. Simply add a reference in the client project to the assembly containing the type, and both the client and service can use the same exact class. Trivial. – John Saunders Jan 27 '12 at 13:51

0 Answers0