Baradhwaj
Baradhwaj

Reputation: 13

using custom objects in webservices in asp.net

I have a custom object which needs to be sent to a queue as a message . I am using a web service to fetch the request from a website , build the object and send the object as a request to the queue. On debugging the webservice , the object instance does not save the assigned values Eg:

Student  cls = new Student();
cls.FirstName="aa";

On viewing the attribute cls.FirstName, I see the value aa not being assigned. This object is sent to the queue and there I get an Object Reference Error . It is because the object does not have any value. Kindly let me know a proper approach of working with objects inside a webservice in asp.net. Framework: 4.0.

Upvotes: 0

Views: 24

Answers (1)

rafat
rafat

Reputation: 817

There are no differences between web-services and other section in case of using objects. I am giving you a sample Example... This is a sample model:

public class Student
{
    public string firstName { set; get; }
    public string LastName { set; get; }
}

The following is the controller code:

Student data = new Student();
data.firstName = "some text";

Upvotes: 1

Related Questions