How to pass an arraylist filled with a list of objects to a web service and retrive the arraylist back from the client side

Posted by Amitmani2000 under C# on 11/29/2008 | Views : 17661 | Status : [Member] | Replies : 1
I am writing a web method in the web service where i am passing an arrayList as an input parameter. While consuming that web service in client application it is giving error.

WEB SERVICE:----------

[WebMethod(MessageName = "SetPatientRegistration", Description = "Insert PatientRegistration")]
public string SetPatientRegistrationInformation(ArrayList PatientInformaListObj)
{
string strReturn = string.Empty;
try
{
ICollection icolRegData = PatientInformaListObj;
RegistrationDataModel patRegDataModel = new RegistrationDataModel();
patRegDataModel = (RegistrationDataModel)icolRegData;
strReturn = PatRegObj.SetPatientRegistration(patRegDataModel);
}
catch (Exception ex)
{
log.Source = "Patientregistration:exception";
log.WriteEntry(ex.ToString());
}
return strReturn;

}

CLIENT APPLICATION : --------------------


protected void imgBtnRecord_Click(object sender, ImageClickEventArgs e)
{
string strMRNo;

RegistrationDataModel registration = null;
PatientRegistrationFacadeWcf patientRegistration = null;


try
{

registration = new RegistrationDataModel();

ArrayList regArryListObj = new ArrayList();
regArryListObj.Add(registration);
strMRNo = twoFieldObj.SetPatientRegistrationInformation(regArryListObj);

if ((Session["MRNO"].ToString() == "") && (txtMrNo.Text == "" ))
{
txtMrNo.Text = strMRNo.Trim();
lblMsg.Text = "Patient Registration Successful";
lblMsg.Text += "<br/> Patient Account No is " + strMRNo.Trim();
}
else
{
lblMsg.Text = "Patient Registration Successful";
}
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "SuccessScript", "<script language='javascript'>alert('Update insurance details.');</script>");
}

}
catch (Exception ex)
{
log.Source = "Submit";
log.WriteEntry(ex.ToString());
lblMsg.Text = "Patient Registration Unsuccessful";
}
}

I will be thankful and appriciate any immediate help on this.




Responses

Posted by: Raja on: 11/29/2008 [Member] Starter

Up
0
Down
Hope following urls will help you.

http://forums.asp.net/p/1343567/2729562.aspx

http://geekswithblogs.net/WayneMagnum/archive/2008/01/24/custom-collection-parameter-in-a-web-service.aspx

Thanks

Regards,
Raja, USA

Amitmani2000, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response