ASP.NET SOAP Server/Client with Complex Types

Posted on 2009-12-29
Last Modified: 2012-05-08
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

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();
Question by:desigone
    LVL 35

    Accepted Solution

    Organization is a class and it is not instantiated. Try:
    VerifyInsurance.RequestorInformation info = new VerifyInsurance.RequestorInformation();
    info.Organization = new Organization();
    info.Organization.Name = "Test Org";

    LVL 35

    Expert Comment

    by:Miguel Oz
    The way to verify that the line below is missing, is to put a breakpoint and check the organization class values in the debugger.

    Happy new year,


    Author Comment

    That was it. Thanks for the help!!!

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Here I am going to explain creating proxies at runtime for WCF Service. So basically we use to generate proxies using Add Service Reference and then giving the Url of the WCF service then generate proxy files at client side. Ok, what if something ge…
    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now