需要有关将自定义对象(类)传递给Web服务的帮助 [英] Need help on passing custom objects (classes) to web service

查看:50
本文介绍了需要有关将自定义对象(类)传递给Web服务的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我目前正在开发一项网络服务,用于检索员工的数据

表。我想向

webservice发送和检索自定义员工类。我目前编写了自定义员工类,并将其作为单独的库(employee.dll)构建了

。这个employee.dll是由web服务和windows应用程序引用的



当我将这个类发送到webservice时遇到以下问题。


1.程序和功能没有被序列化。即当

webservice返回此类时,我无法访问程序和

函数来操作类中的数据。

有人能让我知道如何解决这个问题吗?我遇到了麻烦,而且他们非常需要帮助。请指教。


谢谢,

Noel

解决方案

这些方法永远不会在Web服务中序列化,只有数据(状态)。你可以将
序列化并反序列化为相同的类型,但它需要对你的代理类进行一些手动更改(你需要参考
$) b $ b员工集会,而不是代理生成的类型。


-

Manohar Kamath

编辑,.netWire
www.dotnetwire.com

" Noel" ; <无**** @ nospam.com>在留言中写道

新闻:Ol ************* @ tk2msftngp13.phx.gbl ...

你好,

我正在开发一个从
员工表中检索数据的Web服务。我想向/从
webservice发送和检索自定义员工类。我目前编写了自定义员工类,并将
构建为一个单独的库(employee.dll)。 web服务和Windows应用程序都引用了这个employee.dll。

当我将这个类发送到web服务时,我遇到了以下问题。
1.程序和功能未进行序列化。即当
webservice返回此类时,我无法访问程序和
函数来操作类中的数据。

有人能让我知道我是怎么做的可以解决这个问题吗?我遇到了麻烦,我非常需要帮助。请指教。

谢谢,
Noel



感谢Manohar的回复。


当我尝试引用员工程序集而不是代理生成的

类型时,我收到了无效的类型转换错误。顺便说一句,我正在尝试将

员工对象作为参考传递给Web服务。有没有办法在无效的类型转换错误周围获得




提前致谢。


" ; Manohar Kamath < MK ***** @ TAKETHISOUTkamath.com>在留言中写道

新闻:%2 **************** @ tk2msftngp13.phx.gbl ...

方法永远不会在Web服务中序列化,只有数据(状态)。
您可以序列化和反序列化为相同的类型,但它需要对您的代理类进行一些手动更改(您需要引用
员工程序集,而不是代理生成的类型) )。

-
Manohar Kamath
编辑,.netWire
www.dotnetwire.com

" Noel" <无**** @ nospam.com>在消息中写道
新闻:Ol ************* @ tk2msftngp13.phx.gbl ...

你好,

我正在开发一个Web服务,它从


员工

表中检索数据。我想发送和检索自定义员工类


webservice。我目前已经编写了自定义员工类,并且


构建为一个单独的库(employee.dll)。 web服务和Windows应用程序都引用了这个employee.dll。

当我将这个类发送到web服务时,我遇到了以下问题。
1.程序和功能未进行序列化。即,当
webservice返回此类时,我无法访问程序和
函数来操作类中的数据。

有人能让我知道我是怎么回事可以解决这个问题吗?我遇到麻烦
,我非常需要帮助。请指教。

谢谢,
Noel




可以请发贴代码片段?谢谢!


-

Manohar Kamath

编辑,.netWire
www.dotnetwire.com

" Noel" <无**** @ nospam.com>写在消息

新闻:un ************** @ TK2MSFTNGP14.phx.gbl ...

感谢回复Manohar 。

当我尝试引用员工程序集而不是代理生成的
类型时,我得到一个无效的类型转换错误。顺便说一句,我正在尝试将
员工对象传递给Web服务作为参考。有没有办法围绕无效的类型转换错误?

提前致谢。

Manohar Kamath < MK ***** @ TAKETHISOUTkamath.com>在消息中写道
新闻:%2 **************** @ tk2msftngp13.phx.gbl ...

这些方法永远不会序列化web服务,只有数据(状态)。


可以序列化和反序列化为相同的类型,但它需要一些手动更改您的代理类(您需要引用
员工程序集,而不是代理生成的类型)。

-
Manohar Kamath
编辑,.netWire
www.dotnetwire.com

" Noel" <无**** @ nospam.com>在消息中写道
新闻:Ol ************* @ tk2msftngp13.phx.gbl ...

你好,

我正在开发一个Web服务,它从


员工

表中检索数据。我想从/ blockquote class =post_quotes>

webservice发送和检索自定义员工类


。我目前已经编写了自定义员工类,并且


构建为一个单独的库(employee.dll)。 web服务和Windows应用程序都引用了这个employee.dll。

当我将这个类发送到web服务时,我遇到了以下问题。
1.程序和功能未进行序列化。即当


webservice返回此类时,我无法访问程序和
函数来操作类中的数据。
有人能告诉我如何解决这个问题吗?我遇到了麻烦,急需帮助。请指教。

谢谢,
Noel





Hello,

I''m currently developing a web service that retrieves data from an employee
table. I would like to send and retrieve a custom employee class to/from the
webservice. I have currently coded the custom employee class and have built
it as a separate library (employee.dll). This employee.dll is being
referenced by both the web service and the windows application.

I face the following problem when I send this class to the webservice.

1. The procedures and functions are not getting serialized. i.e. when the
webservice returns this class, I''m unable to access the procedures and
functions for manipulating the data in the class.

Could someone let me know how I could solve this issue? I''m in trouble and
am badly in need of help. Please advise.

Thanks,
Noel

解决方案

The methods are never serialized in web services, only data (state) is. You
could serialize and de-serialize into the same type, but it will require
some manual changes to your proxy classes (you need to reference the
employee assembly, instead of proxy-generated types).

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"Noel" <no****@nospam.com> wrote in message
news:Ol*************@tk2msftngp13.phx.gbl...

Hello,

I''m currently developing a web service that retrieves data from an employee table. I would like to send and retrieve a custom employee class to/from the webservice. I have currently coded the custom employee class and have built it as a separate library (employee.dll). This employee.dll is being
referenced by both the web service and the windows application.

I face the following problem when I send this class to the webservice.

1. The procedures and functions are not getting serialized. i.e. when the
webservice returns this class, I''m unable to access the procedures and
functions for manipulating the data in the class.

Could someone let me know how I could solve this issue? I''m in trouble and
am badly in need of help. Please advise.

Thanks,
Noel



Thanks for the reply Manohar.

When I try to reference the employee assembly instead of proxy-generated
types, I get an invalid type-cast error. BTW, I''m trying to pass the
employee object to the web-service as a reference. Is there a way to get
around the invalid type cast error?

Thanks in advance.

"Manohar Kamath" <mk*****@TAKETHISOUTkamath.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...

The methods are never serialized in web services, only data (state) is. You could serialize and de-serialize into the same type, but it will require
some manual changes to your proxy classes (you need to reference the
employee assembly, instead of proxy-generated types).

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"Noel" <no****@nospam.com> wrote in message
news:Ol*************@tk2msftngp13.phx.gbl...

Hello,

I''m currently developing a web service that retrieves data from an


employee

table. I would like to send and retrieve a custom employee class to/from


the

webservice. I have currently coded the custom employee class and have


built

it as a separate library (employee.dll). This employee.dll is being
referenced by both the web service and the windows application.

I face the following problem when I send this class to the webservice.

1. The procedures and functions are not getting serialized. i.e. when the webservice returns this class, I''m unable to access the procedures and
functions for manipulating the data in the class.

Could someone let me know how I could solve this issue? I''m in trouble and am badly in need of help. Please advise.

Thanks,
Noel




Could you please post the code snippets? Thanks!

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"Noel" <no****@nospam.com> wrote in message
news:un**************@TK2MSFTNGP14.phx.gbl...

Thanks for the reply Manohar.

When I try to reference the employee assembly instead of proxy-generated
types, I get an invalid type-cast error. BTW, I''m trying to pass the
employee object to the web-service as a reference. Is there a way to get
around the invalid type cast error?

Thanks in advance.

"Manohar Kamath" <mk*****@TAKETHISOUTkamath.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...

The methods are never serialized in web services, only data (state) is.


You

could serialize and de-serialize into the same type, but it will require
some manual changes to your proxy classes (you need to reference the
employee assembly, instead of proxy-generated types).

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"Noel" <no****@nospam.com> wrote in message
news:Ol*************@tk2msftngp13.phx.gbl...

Hello,

I''m currently developing a web service that retrieves data from an


employee

table. I would like to send and retrieve a custom employee class

to/from

the

webservice. I have currently coded the custom employee class and have


built

it as a separate library (employee.dll). This employee.dll is being
referenced by both the web service and the windows application.

I face the following problem when I send this class to the webservice.

1. The procedures and functions are not getting serialized. i.e. when


the webservice returns this class, I''m unable to access the procedures and
functions for manipulating the data in the class.

Could someone let me know how I could solve this issue? I''m in trouble and am badly in need of help. Please advise.

Thanks,
Noel





这篇关于需要有关将自定义对象(类)传递给Web服务的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆