G
Guest
I am writing a webservice that has a method which requires an array of a custom object. I am having problems understanding why a few things are occuring
My webservice looks like this
namespace WSTes
/// <summary
/// Summary description for Service1
/// </summary
[WebService(Namespace="http://localhost")
public class Service1 : System.Web.Services.WebServic
[WebMethod
public string Test(DataField[] dfl
return dfl.Length.ToString()
public class DataFiel
public string FieldName=""
public string FieldValue=""
In my client I am accessing the method like this
localhost.Service1 proxy = new localhost.Service1();
localhost.DataField[] df = new localhost.DataField[1]
df[0] = new localhost.DataField()
df[0].FieldName="test"
df[0].FieldValue="user"
proxy.Test(df)
My question is why do I have to assign df[0] to a new instance of DataField when I declared df as a DataField array? If I remove the df[0] = new localhost.DataField(); line I get an object reference not set to an instance of an object error
Maybe I am looking at this all wrong. Is there a better way to pass an array of structured data to a webservice? I switched between using a struct and a class, but both of them act the same way (maybe struct has a bit better performance)
Any help would be greatly appreciated.
My webservice looks like this
namespace WSTes
/// <summary
/// Summary description for Service1
/// </summary
[WebService(Namespace="http://localhost")
public class Service1 : System.Web.Services.WebServic
[WebMethod
public string Test(DataField[] dfl
return dfl.Length.ToString()
public class DataFiel
public string FieldName=""
public string FieldValue=""
In my client I am accessing the method like this
localhost.Service1 proxy = new localhost.Service1();
localhost.DataField[] df = new localhost.DataField[1]
df[0] = new localhost.DataField()
df[0].FieldName="test"
df[0].FieldValue="user"
proxy.Test(df)
My question is why do I have to assign df[0] to a new instance of DataField when I declared df as a DataField array? If I remove the df[0] = new localhost.DataField(); line I get an object reference not set to an instance of an object error
Maybe I am looking at this all wrong. Is there a better way to pass an array of structured data to a webservice? I switched between using a struct and a class, but both of them act the same way (maybe struct has a bit better performance)
Any help would be greatly appreciated.