ASP.NET SOAP Server/Client with Complex Types
-
Trying to build a SOAP web service using complex types and hit a road block. I am using VS to create a web reference to the SOAP service. ASP.NET 2.0, C#. Getting the following error on the client: System.NullReferenceException: Object reference not set to an instance of an object. On the line setting the name on the SOAP client below, info.Organization.Name = "Test Org"; Here is what I have so far: SOAP Web Service
[WebMethod]
public string CoverageRequest(RequestorInformation info)
{
return info.Organization.Name;
}public class RequestorInformation
{
public Organization Organization;
}public class Organization
{
public Organization() {}private string \_Name; public string Name { get { return \_Name; } set { \_Name = value; } }
}
SOAP Client
VerifyInsurance.RequestorInformation info = new VerifyInsurance.RequestorInformation();
info.Organization.Name = "Test Org";VerifyInsurance verify = new VerifyInsurance();
verify.CoverageRequest(info); -
Trying to build a SOAP web service using complex types and hit a road block. I am using VS to create a web reference to the SOAP service. ASP.NET 2.0, C#. Getting the following error on the client: System.NullReferenceException: Object reference not set to an instance of an object. On the line setting the name on the SOAP client below, info.Organization.Name = "Test Org"; Here is what I have so far: SOAP Web Service
[WebMethod]
public string CoverageRequest(RequestorInformation info)
{
return info.Organization.Name;
}public class RequestorInformation
{
public Organization Organization;
}public class Organization
{
public Organization() {}private string \_Name; public string Name { get { return \_Name; } set { \_Name = value; } }
}
SOAP Client
VerifyInsurance.RequestorInformation info = new VerifyInsurance.RequestorInformation();
info.Organization.Name = "Test Org";VerifyInsurance verify = new VerifyInsurance();
verify.CoverageRequest(info);The Organization present in the object info is null. Try this VerifyInsurance.RequestorInformation info = new VerifyInsurance.RequestorInformation(); info.Organization = new Organization(); info.Organization.Name = "Test Org"; VerifyInsurance verify = new VerifyInsurance(); verify.CoverageRequest(info); This should work.