Hi,
I don't agree with your conclusions - you can return just about any type at
all as long as that type is serializable, so it isn't limited to simple
types and dataset.
As far as property serialization, the property has to be read/write, so you
have to have a setter and getter if you are serializing thru properties.
There are many many attributes that control serialization. Start with the
following link:
http://msdn.microsoft.com/library/en...ibutesthatcont
rolserialization.asp
I hope this helps
Dan Rogers
Microsoft Corporation
--------------------
Thread-Topic: WebService returns a custom object
thread-index: AcTpAeb8ynnmplmuTuqiOV21bPTwUA==
X-WBNR-Posting-Host: 63.108.25.252
From: =?Utf-8?B?bXR2?= <mt*@discussions.microsoft.com>
References: <F3**********************************@microsoft.co m>
<kz**************@cpmsftngxa10.phx.gbl>
Subject: RE: WebService returns a custom object
Date: Thu, 23 Dec 2004 07:13:05 -0800
Lines: 133
Message-ID: <77**********************************@microsoft.co m>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:8289
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices
Dan:
I created tests to see what can be exposed via web service, and just like
what you are saying here. WS can expose only the following types as
Property:
primitive types (long, int, string...) and DataSet. And the Property must
also have both Get and Set. Is this the correct observation?
Do you know where in the document or Microsoft sites may have complete
information about this?
Thanks.
"Dan Rogers" wrote:
Hi,
You're making a common mistake - treating the classes on the client side
as if they were remote versions of the classes on the service side. For Web
Service, you cannot safely assume implementation passes over the wire -
in fact only the public data items get mirrored (approximately) on the wire
- based on the only descriptive information exposed - the XML schema
referenced in the WSDL description of your service.
So the line that is failing is due to you assiming that the proxy data
class exposes behaviors. For WS based designs, you should avoid any
attempt to share implementation like this - and assume that your data
classes are merely data bags, and not encapsulate behavior into them that
you expect the caller to use.
In short - don't expose methods on the classes you use as method
arguments or return types. Try to externalize your business logic so that the
method interface serves only as a data contract. Try to not assume that the web
service infrastructure or any commercial tools will provide a client side
programming model that mirrors that which you have within the service
implementation, and don't make your programming model rely on internal
methods on your data types.
I hope this helps
Dan Rogers
Microsoft Corporation
--------------------
Thread-Topic: WebService returns a custom object
thread-index: AcTobLK9GSbhFUcYQM6f5YLJ1XNxGA==
X-WBNR-Posting-Host: 63.108.25.252
From: =?Utf-8?B?bXR2?= <mt*@discussions.microsoft.com>
Subject: WebService returns a custom object
Date: Wed, 22 Dec 2004 13:25:02 -0800
Lines: 65
Message-ID: <F3**********************************@microsoft.co m>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:8272
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices
Hi all,
I have the following code:
================================
Webservice side:
public class MyWS: WebService
{
private myLib.DataObject[] curDataObject;
[WebMethod]
public DataObject[] getData()
{
return this.curDataObject;
}
}
DataObject type is compiled into myLib.dll that is referenced by both my
WebService and my client project.
myLib.cproj:
namespace myLib
{
public class DataObject
{
private DataSet aDS;
public DataTable GetTable(string tableName)
{
....
return aDS.tables[tableName];
}
}
On client: I call the WebMethod like this:
{
...
MyWSProxy.MyWS myWS = new MyWSProxy.MyWS();
MyWebService.myLib.DataObject[] retObj = myWS.getData();
DataTable aDT = retObj[0].GetTable("Table1"); //compile error occurs
...
}
================================
Simply put, both client and WS reference myLib.dll. I understand the
client will get DataObject type which is "defined" in WS when it gets back
result from myWS.getData() method call. However, I expect WS's DataObject type
still
maintains its structure and methods such as GetTable(string). Why does it
lose all of the type's structure? Does it lose all data inside when it is
xmlSerialized?
If so, how come a complex type like DataSet does not lose anything and
can be reconstructed after xml-serialized? And how come DataSet type is the
same
on both WS and client sides?
Thanks.
--
Your 2 cents are worth $milion$. Thanks