By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,154 Members | 1,024 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,154 IT Pros & Developers. It's quick & easy.

passing custom object to webservice

P: n/a
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 techniques are not feasible)

The question is;

Given that I have a Person object with a private set for id.
What is the recommended approac in passing that object to the web service
and still retain the value of id?

Getting the object from the webservice is no problem since I only use the
generated proxy class to achieve this.

Should I create a PersonData with public properties that I pass up to the
webservice or is there any other way?
This could be tricky since if the person object have a list och subitems the
PersonData would need that aswell creating a lot of code doing the same
thing...

I can not use interface because the webservice can not serialize that.

Any pointers to design guidelines or similar is appreciated.
(WCF is not an option right now)

Thanks in advance!

Regards Greger

--
----

Sep 20 '06 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Greger,

It's a good question. You can pass Custom objects to and from Web Services.
In your case , the Person Object, should have Public Properties to depitct
the details of the Person Object

As long as the properties of the Person object are a primitive types, you
don't have to bother too much. Look at the sample below ...

Public Class Person
Public Property PersonId as Integer
Public Property PersonName as String
End Class

If atleast one of the Property of the Person object is a CusomCollection,
you need to consider lot of things before passing objects to and from web
services.
The following scenario has address collection inside Person Object

Public Class Person
Public Property PersonId as Integer
Public Property PersonName as String
Public Propery PersonAddress as AddressCollection
End Class

In such case the Custom Collections are not transmitted directly between web
services and clients. Meaning Custom Collections are passed as Array of
Objecs.
If if it is passed as Array of Objects, you loose tight coupling between
Person Object and AddressCollection property. In this scenario you really
need to figure out a way to maintain the tight coupling between Person Object
and AddressCollection Propery.
The way to do is to enable tight coupling with PersonId. Meaning
have a defintion for PersonId in the AddressCollection.

Please let me know if this reply is useful. If you need more information let
me know.
-
Thanks & Regards,
Sundar Narasimman

"Greger" wrote:
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 techniques are not feasible)

The question is;

Given that I have a Person object with a private set for id.
What is the recommended approac in passing that object to the web service
and still retain the value of id?

Getting the object from the webservice is no problem since I only use the
generated proxy class to achieve this.

Should I create a PersonData with public properties that I pass up to the
webservice or is there any other way?
This could be tricky since if the person object have a list och subitems the
PersonData would need that aswell creating a lot of code doing the same
thing...

I can not use interface because the webservice can not serialize that.

Any pointers to design guidelines or similar is appreciated.
(WCF is not an option right now)

Thanks in advance!

Regards Greger

--
----
Sep 20 '06 #2

P: n/a
Hi Sundar,
Thanxs for the reply.
The gist of the question is when I send the proxy object to the server and
the server tries to recreate my object. It wont be able to set the,
intentionally, private set property. Leaving my object without essential data.

How can I have the framework deserialize my object correctly even though it
has a pricate set?

Regards Greger

--
----

"Sundar Narasimman" wrote:
Greger,

It's a good question. You can pass Custom objects to and from Web Services.
In your case , the Person Object, should have Public Properties to depitct
the details of the Person Object

As long as the properties of the Person object are a primitive types, you
don't have to bother too much. Look at the sample below ...

Public Class Person
Public Property PersonId as Integer
Public Property PersonName as String
End Class

If atleast one of the Property of the Person object is a CusomCollection,
you need to consider lot of things before passing objects to and from web
services.
The following scenario has address collection inside Person Object

Public Class Person
Public Property PersonId as Integer
Public Property PersonName as String
Public Propery PersonAddress as AddressCollection
End Class

In such case the Custom Collections are not transmitted directly between web
services and clients. Meaning Custom Collections are passed as Array of
Objecs.
If if it is passed as Array of Objects, you loose tight coupling between
Person Object and AddressCollection property. In this scenario you really
need to figure out a way to maintain the tight coupling between Person Object
and AddressCollection Propery.
The way to do is to enable tight coupling with PersonId. Meaning
have a defintion for PersonId in the AddressCollection.

Please let me know if this reply is useful. If you need more information let
me know.
-
Thanks & Regards,
Sundar Narasimman

"Greger" wrote:
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 techniques are not feasible)

The question is;

Given that I have a Person object with a private set for id.
What is the recommended approac in passing that object to the web service
and still retain the value of id?

Getting the object from the webservice is no problem since I only use the
generated proxy class to achieve this.

Should I create a PersonData with public properties that I pass up to the
webservice or is there any other way?
This could be tricky since if the person object have a list och subitems the
PersonData would need that aswell creating a lot of code doing the same
thing...

I can not use interface because the webservice can not serialize that.

Any pointers to design guidelines or similar is appreciated.
(WCF is not an option right now)

Thanks in advance!

Regards Greger

--
----
Sep 20 '06 #3

P: n/a
Wow, I didn't even know this was possible... so, you can serialize
custom classes in .net and send them over the web? I am understanding
this right?

Ben

Sundar Narasimman wrote:
Greger,

It's a good question. You can pass Custom objects to and from Web Services.
In your case , the Person Object, should have Public Properties to depitct
the details of the Person Object

As long as the properties of the Person object are a primitive types, you
don't have to bother too much. Look at the sample below ...

Public Class Person
Public Property PersonId as Integer
Public Property PersonName as String
End Class

If atleast one of the Property of the Person object is a CusomCollection,
you need to consider lot of things before passing objects to and from web
services.
The following scenario has address collection inside Person Object

Public Class Person
Public Property PersonId as Integer
Public Property PersonName as String
Public Propery PersonAddress as AddressCollection
End Class

In such case the Custom Collections are not transmitted directly between web
services and clients. Meaning Custom Collections are passed as Array of
Objecs.
If if it is passed as Array of Objects, you loose tight coupling between
Person Object and AddressCollection property. In this scenario you really
need to figure out a way to maintain the tight coupling between Person Object
and AddressCollection Propery.
The way to do is to enable tight coupling with PersonId. Meaning
have a defintion for PersonId in the AddressCollection.

Please let me know if this reply is useful. If you need more information let
me know.
-
Thanks & Regards,
Sundar Narasimman

"Greger" wrote:
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 techniques are not feasible)

The question is;

Given that I have a Person object with a private set for id.
What is the recommended approac in passing that object to the web service
and still retain the value of id?

Getting the object from the webservice is no problem since I only use the
generated proxy class to achieve this.

Should I create a PersonData with public properties that I pass up to the
webservice or is there any other way?
This could be tricky since if the person object have a list och subitems the
PersonData would need that aswell creating a lot of code doing the same
thing...

I can not use interface because the webservice can not serialize that.

Any pointers to design guidelines or similar is appreciated.
(WCF is not an option right now)

Thanks in advance!

Regards Greger

--
----
Sep 21 '06 #4

P: n/a
Hi Ben,

Yes you are right. You can serialize custom objects over the web . You can
even serialize custom object collections.

Thanks & Regards,
Sundar

"Ben Joyce" wrote:
Wow, I didn't even know this was possible... so, you can serialize
custom classes in .net and send them over the web? I am understanding
this right?

Ben

Sundar Narasimman wrote:
Greger,

It's a good question. You can pass Custom objects to and from Web Services.
In your case , the Person Object, should have Public Properties to depitct
the details of the Person Object

As long as the properties of the Person object are a primitive types, you
don't have to bother too much. Look at the sample below ...

Public Class Person
Public Property PersonId as Integer
Public Property PersonName as String
End Class

If atleast one of the Property of the Person object is a CusomCollection,
you need to consider lot of things before passing objects to and from web
services.
The following scenario has address collection inside Person Object

Public Class Person
Public Property PersonId as Integer
Public Property PersonName as String
Public Propery PersonAddress as AddressCollection
End Class

In such case the Custom Collections are not transmitted directly between web
services and clients. Meaning Custom Collections are passed as Array of
Objecs.
If if it is passed as Array of Objects, you loose tight coupling between
Person Object and AddressCollection property. In this scenario you really
need to figure out a way to maintain the tight coupling between Person Object
and AddressCollection Propery.
The way to do is to enable tight coupling with PersonId. Meaning
have a defintion for PersonId in the AddressCollection.

Please let me know if this reply is useful. If you need more information let
me know.
-
Thanks & Regards,
Sundar Narasimman

"Greger" wrote:
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 techniques are not feasible)
>
The question is;
>
Given that I have a Person object with a private set for id.
What is the recommended approac in passing that object to the web service
and still retain the value of id?
>
Getting the object from the webservice is no problem since I only use the
generated proxy class to achieve this.
>
Should I create a PersonData with public properties that I pass up to the
webservice or is there any other way?
This could be tricky since if the person object have a list och subitems the
PersonData would need that aswell creating a lot of code doing the same
thing...
>
I can not use interface because the webservice can not serialize that.
>
Any pointers to design guidelines or similar is appreciated.
(WCF is not an option right now)
>
Thanks in advance!
>
Regards Greger
>
--
----
>

Sep 21 '06 #5

P: n/a
Hi Greger,

Niow I can understand your problem better.
There is a way to do that. You can have a Public method in the Remote Object
to update the private property/member of the class.

Your remote Person object can have public and private properties/method.
As you know only Public properties/methods would be serialized back and
forth between Web Services and the Client. Meaning at the client-side, the
proxy will reflect only Public Properties/Methods of the remote object.

You can still call the Public method of the proxy, that inturn will get
executed at the server-side to update your private property/member.

This is really possible.

Pls let me know whether this is useful or you need more information
regarding this
--
Thanks & Regards,
Sundar Narasimman
Technology Specialist
Microsoft .NET
"Greger" wrote:
Hi Sundar,
Thanxs for the reply.
The gist of the question is when I send the proxy object to the server and
the server tries to recreate my object. It wont be able to set the,
intentionally, private set property. Leaving my object without essential data.

How can I have the framework deserialize my object correctly even though it
has a pricate set?

Regards Greger

--
----

"Sundar Narasimman" wrote:
Greger,

It's a good question. You can pass Custom objects to and from Web Services.
In your case , the Person Object, should have Public Properties to depitct
the details of the Person Object

As long as the properties of the Person object are a primitive types, you
don't have to bother too much. Look at the sample below ...

Public Class Person
Public Property PersonId as Integer
Public Property PersonName as String
End Class

If atleast one of the Property of the Person object is a CusomCollection,
you need to consider lot of things before passing objects to and from web
services.
The following scenario has address collection inside Person Object

Public Class Person
Public Property PersonId as Integer
Public Property PersonName as String
Public Propery PersonAddress as AddressCollection
End Class

In such case the Custom Collections are not transmitted directly between web
services and clients. Meaning Custom Collections are passed as Array of
Objecs.
If if it is passed as Array of Objects, you loose tight coupling between
Person Object and AddressCollection property. In this scenario you really
need to figure out a way to maintain the tight coupling between Person Object
and AddressCollection Propery.
The way to do is to enable tight coupling with PersonId. Meaning
have a defintion for PersonId in the AddressCollection.

Please let me know if this reply is useful. If you need more information let
me know.
-
Thanks & Regards,
Sundar Narasimman

"Greger" wrote:
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 techniques are not feasible)
>
The question is;
>
Given that I have a Person object with a private set for id.
What is the recommended approac in passing that object to the web service
and still retain the value of id?
>
Getting the object from the webservice is no problem since I only use the
generated proxy class to achieve this.
>
Should I create a PersonData with public properties that I pass up to the
webservice or is there any other way?
This could be tricky since if the person object have a list och subitems the
PersonData would need that aswell creating a lot of code doing the same
thing...
>
I can not use interface because the webservice can not serialize that.
>
Any pointers to design guidelines or similar is appreciated.
(WCF is not an option right now)
>
Thanks in advance!
>
Regards Greger
>
--
----
>
Sep 21 '06 #6

P: n/a
Hi,

Your information is quite useful and I have one more question to it.

I am having one custom object which I accept as a parameter of my webmethod.
This object is getting generated in my proxy class of the webservice at the
consumer-end.

Now, I am not getting any of my public methods of my custom object in
generated proxy class. I am not getting even constructors.

Actually I am having one private variable of the type "object" in my custom
class "WebResponse". Depending on the type of the value it contains, I am
having public methods to return it's value. but I am not getting any of these
public methods in the proxy class.

Is there any way out here!

Thanks,
Prerak

"Sundar Narasimman" wrote:
Hi Ben,

Yes you are right. You can serialize custom objects over the web . You can
even serialize custom object collections.

Thanks & Regards,
Sundar

"Ben Joyce" wrote:
Wow, I didn't even know this was possible... so, you can serialize
custom classes in .net and send them over the web? I am understanding
this right?

Ben

Sundar Narasimman wrote:
Greger,
>
It's a good question. You can pass Custom objects to and from Web Services.
In your case , the Person Object, should have Public Properties to depitct
the details of the Person Object
>
As long as the properties of the Person object are a primitive types, you
don't have to bother too much. Look at the sample below ...
>
Public Class Person
Public Property PersonId as Integer
Public Property PersonName as String
End Class
>
If atleast one of the Property of the Person object is a CusomCollection,
you need to consider lot of things before passing objects to and from web
services.
The following scenario has address collection inside Person Object
>
Public Class Person
Public Property PersonId as Integer
Public Property PersonName as String
Public Propery PersonAddress as AddressCollection
End Class
>
In such case the Custom Collections are not transmitted directly between web
services and clients. Meaning Custom Collections are passed as Array of
Objecs.
If if it is passed as Array of Objects, you loose tight coupling between
Person Object and AddressCollection property. In this scenario you really
need to figure out a way to maintain the tight coupling between Person Object
and AddressCollection Propery.
The way to do is to enable tight coupling with PersonId. Meaning
have a defintion for PersonId in the AddressCollection.
>
Please let me know if this reply is useful. If you need more information let
me know.
-
Thanks & Regards,
Sundar Narasimman
>
>
>
"Greger" wrote:
>
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 techniques are not feasible)

The question is;

Given that I have a Person object with a private set for id.
What is the recommended approac in passing that object to the web service
and still retain the value of id?

Getting the object from the webservice is no problem since I only use the
generated proxy class to achieve this.

Should I create a PersonData with public properties that I pass up to the
webservice or is there any other way?
This could be tricky since if the person object have a list och subitems the
PersonData would need that aswell creating a lot of code doing the same
thing...

I can not use interface because the webservice can not serialize that.

Any pointers to design guidelines or similar is appreciated.
(WCF is not an option right now)

Thanks in advance!

Regards Greger

--
----
Feb 27 '07 #7

P: n/a
Custom objects are serialized with XmlSerializer, it only transport public
properties.
"Prerak V. Shah" <Prerak V. Sh**@discussions.microsoft.comwrote in message
news:9A**********************************@microsof t.com...
Hi,

Your information is quite useful and I have one more question to it.

I am having one custom object which I accept as a parameter of my
webmethod.
This object is getting generated in my proxy class of the webservice at
the
consumer-end.

Now, I am not getting any of my public methods of my custom object in
generated proxy class. I am not getting even constructors.

Actually I am having one private variable of the type "object" in my
custom
class "WebResponse". Depending on the type of the value it contains, I am
having public methods to return it's value. but I am not getting any of
these
public methods in the proxy class.

Is there any way out here!

Thanks,
Prerak

"Sundar Narasimman" wrote:
>Hi Ben,

Yes you are right. You can serialize custom objects over the web . You
can
even serialize custom object collections.

Thanks & Regards,
Sundar

"Ben Joyce" wrote:
Wow, I didn't even know this was possible... so, you can serialize
custom classes in .net and send them over the web? I am understanding
this right?

Ben

Sundar Narasimman wrote:
Greger,

It's a good question. You can pass Custom objects to and from Web
Services.
In your case , the Person Object, should have Public Properties to
depitct
the details of the Person Object

As long as the properties of the Person object are a primitive types,
you
don't have to bother too much. Look at the sample below ...

Public Class Person
Public Property PersonId as Integer
Public Property PersonName as String
End Class

If atleast one of the Property of the Person object is a
CusomCollection,
you need to consider lot of things before passing objects to and from
web
services.
The following scenario has address collection inside Person Object

Public Class Person
Public Property PersonId as Integer
Public Property PersonName as String
Public Propery PersonAddress as AddressCollection
End Class

In such case the Custom Collections are not transmitted directly
between web
services and clients. Meaning Custom Collections are passed as Array
of
Objecs.
If if it is passed as Array of Objects, you loose tight coupling
between
Person Object and AddressCollection property. In this scenario you
really
need to figure out a way to maintain the tight coupling between
Person Object
and AddressCollection Propery.
The way to do is to enable tight coupling with PersonId.
Meaning
have a defintion for PersonId in the AddressCollection.

Please let me know if this reply is useful. If you need more
information let
me know.
-
Thanks & Regards,
Sundar Narasimman

"Greger" wrote:

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 techniques are not feasible)

The question is;

Given that I have a Person object with a private set for id.
What is the recommended approac in passing that object to the web
service
and still retain the value of id?

Getting the object from the webservice is no problem since I only
use the
generated proxy class to achieve this.

Should I create a PersonData with public properties that I pass up
to the
webservice or is there any other way?
This could be tricky since if the person object have a list och
subitems the
PersonData would need that aswell creating a lot of code doing the
same
thing...

I can not use interface because the webservice can not serialize
that.

Any pointers to design guidelines or similar is appreciated.
(WCF is not an option right now)

Thanks in advance!

Regards Greger

--
----


Mar 8 '07 #8

P: n/a
one of the alternatives:

http://replicrux.com/2008/10/20/pass...b-service.aspx

"Mariano Omar Rodriguez" wrote:
Custom objects are serialized with XmlSerializer, it only transport public
properties.
"Prerak V. Shah" <Prerak V. Sh**@discussions.microsoft.comwrote in message
news:9A**********************************@microsof t.com...
Hi,

Your information is quite useful and I have one more question to it.

I am having one custom object which I accept as a parameter of my
webmethod.
This object is getting generated in my proxy class of the webservice at
the
consumer-end.

Now, I am not getting any of my public methods of my custom object in
generated proxy class. I am not getting even constructors.

Actually I am having one private variable of the type "object" in my
custom
class "WebResponse". Depending on the type of the value it contains, I am
having public methods to return it's value. but I am not getting any of
these
public methods in the proxy class.

Is there any way out here!

Thanks,
Prerak

"Sundar Narasimman" wrote:
Hi Ben,

Yes you are right. You can serialize custom objects over the web . You
can
even serialize custom object collections.

Thanks & Regards,
Sundar

"Ben Joyce" wrote:

Wow, I didn't even know this was possible... so, you can serialize
custom classes in .net and send them over the web? I am understanding
this right?

Ben

Sundar Narasimman wrote:
Greger,
>
It's a good question. You can pass Custom objects to and from Web
Services.
In your case , the Person Object, should have Public Properties to
depitct
the details of the Person Object
>
As long as the properties of the Person object are a primitive types,
you
don't have to bother too much. Look at the sample below ...
>
Public Class Person
Public Property PersonId as Integer
Public Property PersonName as String
End Class
>
If atleast one of the Property of the Person object is a
CusomCollection,
you need to consider lot of things before passing objects to and from
web
services.
The following scenario has address collection inside Person Object
>
Public Class Person
Public Property PersonId as Integer
Public Property PersonName as String
Public Propery PersonAddress as AddressCollection
End Class
>
In such case the Custom Collections are not transmitted directly
between web
services and clients. Meaning Custom Collections are passed as Array
of
Objecs.
If if it is passed as Array of Objects, you loose tight coupling
between
Person Object and AddressCollection property. In this scenario you
really
need to figure out a way to maintain the tight coupling between
Person Object
and AddressCollection Propery.
The way to do is to enable tight coupling with PersonId.
Meaning
have a defintion for PersonId in the AddressCollection.
>
Please let me know if this reply is useful. If you need more
information let
me know.
-
Thanks & Regards,
Sundar Narasimman
>
>
>
"Greger" wrote:
>
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 techniques are not feasible)

The question is;

Given that I have a Person object with a private set for id.
What is the recommended approac in passing that object to the web
service
and still retain the value of id?

Getting the object from the webservice is no problem since I only
use the
generated proxy class to achieve this.

Should I create a PersonData with public properties that I pass up
to the
webservice or is there any other way?
This could be tricky since if the person object have a list och
subitems the
PersonData would need that aswell creating a lot of code doing the
same
thing...

I can not use interface because the webservice can not serialize
that.

Any pointers to design guidelines or similar is appreciated.
(WCF is not an option right now)

Thanks in advance!

Regards Greger

--
----


Oct 26 '08 #9

P: n/a

"Kin" <Ki*@discussions.microsoft.comwrote in message
news:41**********************************@microsof t.com...
one of the alternatives:

http://replicrux.com/2008/10/20/pass...b-service.aspx
This is totally unnecessary. Simply copy the properties from one object to
the other.

In WCF you can simply choose to reuse the types.

--
John Saunders | MVP - Connected System Developer

Oct 26 '08 #10

This discussion thread is closed

Replies have been disabled for this discussion.