thavs

thavs

  • NA
  • 38
  • 0

Problem retrieving arraylist from webservice

Jun 25 2007 8:40 AM
Hi

I'm having trouble retrieving an arraylist from my webservice.

My webmethod returns a collection of object Task as follows.

[WebMethod]

[return: XmlElement(typeof(Workflow.Task))]

public List<Task> GetAllTasks()

{

SqlConnection cn = null;

SqlDataReader rd = null;

try

{

cn = new SqlConnection(connection);

SqlCommand cmd = new SqlCommand("GetAllTasks",cn);

cmd.CommandType = CommandType.StoredProcedure;

cn.Open();

rd = cmd.ExecuteReader();

tasks.Clear();

while (rd.Read())

{

int actID = 0;

int nodeID = 0;

int userID = 0;

if (!rd.IsDBNull(0)) actID = Convert.ToInt32(rd.GetValue(0));

if (!rd.IsDBNull(1)) nodeID = Convert.ToInt32(rd.GetValue(1));

if (!rd.IsDBNull(2)) userID = Convert.ToInt32(rd.GetValue(2));

Task tk = new Task(actID, nodeID, userID);

tasks.Add(tk);

}

rd.Close();

cn.Close();

return tasks;

}

catch (Exception ex)

{ throw new Exception(ex.Message); }

}

[Serializable, XmlInclude(typeof(Task))]

public class Task

{

private int actID = 0;

private int nodeID = 0;

private int userID = 0;

public int ActionID

{

get { return actID; }

set { actID = value; }

}

public int NodeID

{

get { return nodeID; }

set { nodeID = value; }

}

public int UserID

{

get { return userID; }

set { userID = value; }

}

public Task()

{

}

internal Task(int ActionID, int NodeID, int UserID)

{

this.actID = ActionID;

this.nodeID = NodeID;

this.userID = UserID;

}

}



In my web app I'm trying to access the arraylist as follows but it returns a blank arraylist. But if I step thru it the webservice arraylist contains value but is not returning it to the application.

web app code:

localhost.Workflow wFlowService = new localhost.Workflow();

ArrayList Tasks = new ArrayList(wFlowService.GetAllTasks());



Can anyone assist me here.

Thanks
Thav


Answers (1)