?
Solved

ASP.NET SOAP Server/Client with Complex Types

Posted on 2009-12-29
3
Medium Priority
?
588 Views
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

[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);
0
Comment
Question by:desigone
  • 2
3 Comments
 
LVL 36

Accepted Solution

by:
Miguel Oz earned 2000 total points
ID: 26141865
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";

0
 
LVL 36

Expert Comment

by:Miguel Oz
ID: 26141873
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,
MS

0
 

Author Comment

by:desigone
ID: 26141897
That was it. Thanks for the help!!!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month13 days, 15 hours left to enroll

807 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