Webservice beginner - need some help

O

Ori

Hi,

I'm a beginner with web services and I need some help.


I build my web-service and I was able to deploy it and succeed to use
it by other application.

Now I was tiring to add a new function which returns an instance of a
class which I have in the web service project (which holds some
properties of a user in my system).

As I see, I'm able to execute the function, but I'm not able to access
the properties which I exposed in the class.

What should I do in order to be able to access to those properties?
Should I need to inherit from a specific class? mark the properties
with a special attributes?

I would like to say that this class isn't supposed to function as a
web service but only a "data carrier".

Here is my class:

public class PermissionInfo
{
protected long _userId;
protected string _logonName;
protected string _firstName;
protected string _lastName;
protected string _domainName;
protected int _domainId;
protected Permissions _permissionLevel;
protected string _moduleName;
protected int _moduleId;


public PermissionInfo()
{
//
// TODO: Add constructor logic here
//
}
public bool LoadPermission(string logonName,int moduleId)
{
// Set up parameters
SqlParameter [] arParms = new SqlParameter[2];
///Add the parameters to the array
arParms[0] = new SqlParameter("@LogonName",logonName);
arParms[1] = new SqlParameter("@ModuleId",moduleId);
DataTable dt = SqlHelper.ExecuteDataset(Global.GetConnectionString(),
CommandType.StoredProcedure,
"UC_GetUser_Module_Authorization_Info",
arParms).Tables[0];

_moduleId = moduleId;
_logonName = logonName;

if(dt.Rows.Count>0)
{
_userId = Convert.ToInt64(dt.Rows[0]["UserId"]);
_firstName= dt.Rows[0]["FirstName"].ToString();
_lastName = dt.Rows[0]["LastName"].ToString();
_domainName = dt.Rows[0]["DomainName"].ToString();
_moduleName = dt.Rows[0]["ModuleName"].ToString();
_permissionLevel = (Permissions)dt.Rows[0]["PermissionId"];
return true;
}
return false;
}


public Permissions PermissionLevel
{
get{return _permissionLevel;}
}
public string DomainName
{
get{return _domainName;}
}
public string FirstName
{
get{return _firstName;}
}
public string LastName
{
get{return _lastName;}
}
public string ModuleName
{
get{return _moduleName;}
}
Thanks,

Ori.
 
J

Jan Tielens

Your properties are read only (only a getter), so you need to add for each
property a setter. You can't serialize read only properties...
 
J

Jan Tielens

For example:
public Permissions PermissionLevel
{
get{return _permissionLevel;}
set {_permissionLevel = value;}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top