473,387 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Need help on passing custom objects (classes) to web service

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

Nov 23 '05 #1
12 5276
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

Nov 23 '05 #2
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


Nov 23 '05 #3
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



Nov 23 '05 #4
Noel

What about creating serialisable types from schema definitions and then
passing the xml as a XmlNode or XmlDocument and then deserialising and
reserialising inside the web service. That way if anyone else needs to use
your web service, you only need publish the schema and wsdl and anyone could
bind to it.

As for the employee.dll, could you expose the functionality as a web
service? It may make your application a bit chatty on the wire depending on
how you use it, but a least you won't have as many deployment headaches
(albeit reduced with .net).

Apologies if I've misunderstood Manohar's comment, but manual changes to the
web service proxy would be lost if you made a change to the web service and
refreshed the reference at the client end.

HTH

Glenn

"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



Nov 23 '05 #5
There is so little code, that I thought I'd explain a bit more. Please do
not mistake me, just let me know if you still need the code and I'll send it
across.

This is what I have in the project:

1. Employee project (stand alone executable - windows application)
2. Employee Class Built as a library. This has been compiled as a library
just to allow me to use in both the web services as well as the Employee
Project.
3. Web service that interfaces with the database.

The web service and the employee project reference the employee library.

In the windows application, I create an instance of webservice and pass the
employee object as reference, like:

Dim wsEmp as New EmployeeWebService
Dim obj As EmployeeObject
' obj is sent across by reference - Error occurs here
' (like Employee Object cannot be
' typecast to ' EmployeeWebService.EmployeeObject)
wsEmp.GetData(obj)

In the web service, I create an instance of the employee object and fill it
with data from the webservice, like:

Sub GetData(ByRef obj As EmployeeObject)
obj = New EmployeeObject
' Access database and fill Employee object with data
FillData(obj)
End Sub

I get an error "Invalid Typecast" in wsEmp.GetData(obj).

Both the objects (Windows and Web Service) are the same and refer to
Common.EmployeeObject. I'm wondering if I need to mark the
Common.EmployeeObject as serializable (Not sure though).

Thanks in advance.

"Manohar Kamath" <mk*****@TAKETHISOUTkamath.com> wrote in message
news:ee**************@TK2MSFTNGP09.phx.gbl...
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
>
>
>



Nov 23 '05 #6
Glenn, I like your idea. Could you please point me to some source code or
website where I could learn how to do this? I'll be glad if you could help.

Thanks in advance.

"Glenn" <cs****@blackwinter.net> wrote in message
news:OW**************@tk2msftngp13.phx.gbl...
Noel

What about creating serialisable types from schema definitions and then
passing the xml as a XmlNode or XmlDocument and then deserialising and
reserialising inside the web service. That way if anyone else needs to use your web service, you only need publish the schema and wsdl and anyone could bind to it.

As for the employee.dll, could you expose the functionality as a web
service? It may make your application a bit chatty on the wire depending on how you use it, but a least you won't have as many deployment headaches
(albeit reduced with .net).

Apologies if I've misunderstood Manohar's comment, but manual changes to the web service proxy would be lost if you made a change to the web service and refreshed the reference at the client end.

HTH

Glenn

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



Nov 23 '05 #7
Noel

Not a problem, but can't do it this evening, Man City vs Bolton and I've got
a date with the pub, I'll post some more detail tommorrow morning (GMT ).

Cheers

Glenn

"Noel" <no****@nospam.com> wrote in message
news:Ou**************@TK2MSFTNGP09.phx.gbl...
Glenn, I like your idea. Could you please point me to some source code or
website where I could learn how to do this? I'll be glad if you could help.
Thanks in advance.

"Glenn" <cs****@blackwinter.net> wrote in message
news:OW**************@tk2msftngp13.phx.gbl...
Noel

What about creating serialisable types from schema definitions and then
passing the xml as a XmlNode or XmlDocument and then deserialising and
reserialising inside the web service. That way if anyone else needs to use
your web service, you only need publish the schema and wsdl and anyone

could
bind to it.

As for the employee.dll, could you expose the functionality as a web
service? It may make your application a bit chatty on the wire depending on
how you use it, but a least you won't have as many deployment headaches
(albeit reduced with .net).

Apologies if I've misunderstood Manohar's comment, but manual changes to

the
web service proxy would be lost if you made a change to the web service

and
refreshed the reference at the client end.

HTH

Glenn

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



Nov 23 '05 #8
Noel,

Here's the problem:

You are sending in obj, which is of different type than the proxy type:

wsEmp.GetData(obj)

It is expecting: EmployeeWebService.EmployeeObject -- this is a proxy type,
whereas your EmployeeObject is in a different namespace.

To remedy this, you need to manually change your proxy class, remove the
type EmployeeWebService.EmployeeObject from the class, and add a reference
to your Employee library in the proxy class (using Imports). This tricks the
compiler into thinking that you are using the proxy type, while it is
actually using your custom type.

Hope that helps.

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"Noel" <no****@nospam.com> wrote in message
news:O6**************@TK2MSFTNGP15.phx.gbl...
There is so little code, that I thought I'd explain a bit more. Please do
not mistake me, just let me know if you still need the code and I'll send it across.

This is what I have in the project:

1. Employee project (stand alone executable - windows application)
2. Employee Class Built as a library. This has been compiled as a library
just to allow me to use in both the web services as well as the Employee
Project.
3. Web service that interfaces with the database.

The web service and the employee project reference the employee library.

In the windows application, I create an instance of webservice and pass the employee object as reference, like:

Dim wsEmp as New EmployeeWebService
Dim obj As EmployeeObject
' obj is sent across by reference - Error occurs here
' (like Employee Object cannot be
' typecast to ' EmployeeWebService.EmployeeObject)
wsEmp.GetData(obj)

In the web service, I create an instance of the employee object and fill it with data from the webservice, like:

Sub GetData(ByRef obj As EmployeeObject)
obj = New EmployeeObject
' Access database and fill Employee object with data
FillData(obj)
End Sub

I get an error "Invalid Typecast" in wsEmp.GetData(obj).

Both the objects (Windows and Web Service) are the same and refer to
Common.EmployeeObject. I'm wondering if I need to mark the
Common.EmployeeObject as serializable (Not sure though).

Thanks in advance.

"Manohar Kamath" <mk*****@TAKETHISOUTkamath.com> wrote in message
news:ee**************@TK2MSFTNGP09.phx.gbl...
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
> >
> >
> >
>
>



Nov 23 '05 #9
Yes, you will lose the changes to the proxy classes if you re-generated the
proxy class. However, this is one of those "to-do" if this ever happened.
And also, once you have the web service solidified, the proxy class should
never change -- as a change would mean a change in the version.

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"Glenn" <cs****@blackwinter.net> wrote in message
news:OW**************@tk2msftngp13.phx.gbl...
Noel

What about creating serialisable types from schema definitions and then
passing the xml as a XmlNode or XmlDocument and then deserialising and
reserialising inside the web service. That way if anyone else needs to use your web service, you only need publish the schema and wsdl and anyone could bind to it.

As for the employee.dll, could you expose the functionality as a web
service? It may make your application a bit chatty on the wire depending on how you use it, but a least you won't have as many deployment headaches
(albeit reduced with .net).

Apologies if I've misunderstood Manohar's comment, but manual changes to the web service proxy would be lost if you made a change to the web service and refreshed the reference at the client end.

HTH

Glenn

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



Nov 23 '05 #10
Could you please throw some light on how the versioning needs to be done for
the proxy class?

One more question regarding the custom class:

I'm not sure what's the preferred/best method to retrieve the records from
the webservice. Which one is better when deciding to retrieve data from web
service?

1. Using Datasets (Multiple datatables can be returned. But could this make
the web service slower than when using custom objects)
2. Custom objects

BTW, when deciding to use custom objects. How should the records be stored
inside the object (I mean what's the industry standard or preferred method
of storing multiple records in a custom object?) Should a dataset/datatable
be used inside the custom object to store data or is there another better
method?

Another question/topic:

The architecture that I want to follow is GUI -> Web service -> Business
Objects -> database.

I would like the application to be highly scalable and load balanced.
Therefore I would like to scale it at the business objects level. If I have
multiple servers with the Business Objects installed/running. How could I
let the web service know

1. Which server to use (depending on load balancing.) BTW to load balance
should I incorporate any logic to the application/webservice?
2. How to supply/notify my web service at run-time the servers that have the
Business Objects running?

Thanks in advance for your valuable inputs.

"Manohar Kamath" <mk*****@TAKETHISOUTkamath.com> wrote in message
news:uj**************@TK2MSFTNGP12.phx.gbl...
Yes, you will lose the changes to the proxy classes if you re-generated the proxy class. However, this is one of those "to-do" if this ever happened.
And also, once you have the web service solidified, the proxy class should
never change -- as a change would mean a change in the version.

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"Glenn" <cs****@blackwinter.net> wrote in message
news:OW**************@tk2msftngp13.phx.gbl...
Noel

What about creating serialisable types from schema definitions and then
passing the xml as a XmlNode or XmlDocument and then deserialising and
reserialising inside the web service. That way if anyone else needs to use
your web service, you only need publish the schema and wsdl and anyone

could
bind to it.

As for the employee.dll, could you expose the functionality as a web
service? It may make your application a bit chatty on the wire depending on
how you use it, but a least you won't have as many deployment headaches
(albeit reduced with .net).

Apologies if I've misunderstood Manohar's comment, but manual changes to

the
web service proxy would be lost if you made a change to the web service

and
refreshed the reference at the client end.

HTH

Glenn

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



Nov 23 '05 #11
Noel

The XML part or exposing the employee.dll functionality as a web service?

With regards to XML serialization

http://msdn.microsoft.com/library/de...us/dnexxml/htm
l/xml01202003.asp

http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemxmlserialization.asp

If your using VS.NET you could use the rather good XML Designer to build
your schema definitions.

As for exposing functionality on the web for an existing DLL, a personal
preference is to create a thin web service wrapper type around the existing
class. Any overloaded methods can be handled using the MessageName property
of the WebMethod attribute.

I've have to say that most of the work I've been doing with XML and web
services in general has been processing data in a single hit. Dealing with
rich client applications may not lend itself to using a serialisation
mechanism.

Thinking about it a bit more, DataSets may be a better solution than having
to worry so much about the serialisation mechanism. I've not personally
used them in web services having been told by a supposedly more learned
colleague not to, but it may be perfect for what you want to do.

I'd check out these articles before attempting to use DataSets with web
services

http://www.oreillynet.com/pub/wlg/2142

http://weblogs.asp.net/aaguiar/archi...03/147208.aspx

Sorry if I've not been much help, I'm extremely hungover.

Glenn

"Noel" <no****@nospam.com> wrote in message
news:Ou**************@TK2MSFTNGP09.phx.gbl...
Glenn, I like your idea. Could you please point me to some source code or
website where I could learn how to do this? I'll be glad if you could help.
Thanks in advance.

"Glenn" <cs****@blackwinter.net> wrote in message
news:OW**************@tk2msftngp13.phx.gbl...
Noel

What about creating serialisable types from schema definitions and then
passing the xml as a XmlNode or XmlDocument and then deserialising and
reserialising inside the web service. That way if anyone else needs to use
your web service, you only need publish the schema and wsdl and anyone

could
bind to it.

As for the employee.dll, could you expose the functionality as a web
service? It may make your application a bit chatty on the wire depending on
how you use it, but a least you won't have as many deployment headaches
(albeit reduced with .net).

Apologies if I've misunderstood Manohar's comment, but manual changes to

the
web service proxy would be lost if you made a change to the web service

and
refreshed the reference at the client end.

HTH

Glenn

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



Nov 23 '05 #12
If you want to return binary objects from the webservice the only way is to
mark your object as [Serializable] then:

On Server:
[WebMethod]
[SoapDocumentMethod(ParameterStyle=SoapParameterSty le.Bare)]
byte[] GetEmployee()
{
Employee employee = new Employee("Eric Cartmen");
MemoryStream memoryStream = new MemoryStream();
BinaryFormatter formater = new BinaryFormatter();
formater.Serialize(memoryStream, employee);
return memoryStream.ToByteArray();
}

On Client:
Employee GetEmployee()
{
byte[] rawEmployee = Service.GetEmployee();
BinaryFormatter formater = new BinaryFormatter();
return (Employee) formater.Deserialize(rawemployee);

----------------------------------------------------------------------------------------------
Lookup MSDN for [SoapDocumentMethod(ParameterStyle=SoapParameterSty le.Bare)]

!!! BEWARE Binary formating is not version safe. i.e. If you change the
version of
your Employee class make shure that Server and Client use the same version.

If this is not accepteble to you use XML Serialization.
"Noel" wrote:
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

Nov 23 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: Stuart Hilditch | last post by:
Hi all, I am hoping that someone with some experience developing nTier apps can give me some advice here. I am writing an nTier web app that began with a Data Access Layer (DAL), Business...
6
by: Scott Zabolotzky | last post by:
I'm trying to pass a custom object back and forth between forms. This custom object is pulled into the app using an external reference to an assembly DLL that was given to me by a co-worker. A...
2
by: PeteZ | last post by:
Can someone help me here. I'm having trouble finding details on how complex objects (eg. an object created in a code behind page that has imbedded object references, collections etc imbedded in...
9
by: Greger | last post by:
Hi, I am building an architecture that passes my custom objects to and from webservices. (Our internal architecture requires me to use webservices to any suggestion to use other remoting...
2
by: Hakan Örnek | last post by:
Hi , I want to parameter passing to my windows sevice. I call service commands like this ; '------------------------------------------------------------ Dim sc As ServiceController sc = New...
2
by: =?Utf-8?B?Y3Nz?= | last post by:
I am new to ASP.net webservice and have a quesiton. Is is possible to pass custom object to a web service (using VB 2005)? My custom object will look like this Public Class Myclass Public...
2
by: grawsha2000 | last post by:
Greetings, I am developing this N-tier business app. The problem I'm facing is when I try to pass business objects (employees, dept..etc) from business tier to data tier,i.e., the add method in...
3
by: =?Utf-8?B?R2hpc3Rvcw==?= | last post by:
Hi all, We have a N-Tier framework and we now create a Web Site App to wotk with this architecture. I add reference from my libraries in the project and creating page and controls is very...
19
by: jsanshef | last post by:
Hi, after a couple of days of script debugging, I kind of found that some assumptions I was doing about the memory complexity of my classes are not true. I decided to do a simple script to...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.