Search code examples
c#winformsfunctionweb-servicesbusiness-logic-layer

How to use class function from asmx Service (BL) from Client C# Winforms


I have different projects in the solution for the Bl service and the Winform Client.

in the Bl project iv'e added a User Class with a function . i managed to find the class from the client but i do not get the function. and the Constructor with the parameters.

this is the BL

the service is added as a web reference in the client project and this is what I get:

i can see the class properties but not the functions.

and this is the class:

public class User
{
    public string FirstName;
    public string LastName;
    public string Email;
    public string PhoneNumber;
    public string PassWord;
    public string UserName;
    public User(string fn, string ln, string un, string pn, string em, string pw)
    {
        FirstName = fn;
        LastName = fn;
        Email = em;
        PhoneNumber = pn;
        PassWord = pw;
        UserName = un;
    }
    public User()
    {
        //
    }
    public void setData(string fn, string ln, string un, string pn, string em, string pw)
    {
        FirstName = fn;
        LastName = fn;
        Email = em;
        PhoneNumber = pn;
        PassWord = pw;
        UserName = un;
    }

}

and this is what I am trying to do eventually :

[WebMethod]
    public DataSet RegisterNewUser(User usr)
    {
        return getDal.RegisterNewUser(usr.UserName, usr.FirstName, usr.LastName, usr.PassWord, usr.Email, usr.PhoneNumber);
    }

to send a user class to the RegisterNewUser

I didn't find any answer here for that problem


Solution

  • Web services cannot serialize code so methods in your classes will not be available to the client proxy (and if you have code in private methods it will not execute). Objects serialized via this method are only data transfer objects - dumb properties.