简体   繁体   English

在asp.net中的webservices中使用自定义对象

[英]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. 我正在使用Web服务从网站获取请求,构建对象并将对象作为请求发送到队列。 On debugging the webservice , the object instance does not save the assigned values Eg: 在调试webservice时,对象实例不会保存分配的值,例如:

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

On viewing the attribute cls.FirstName, I see the value aa not being assigned. 在查看属性cls.FirstName时,我看到未分配值aa。 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. 请让我知道在asp.net中处理Web服务内部对象的正确方法。 Framework: 4.0. 框架:4.0。

There are no differences between web-services and other section in case of using objects. 在使用对象的情况下,Web服务与其他部分之间没有区别。 I am giving you a sample Example... This is a sample model: 我给您提供一个示例Example ...这是一个示例模型:

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";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM