Hi Paul,
From your description, you have a WCF service which use a service method
(operation) to return a typed DataTAble. However, in the client-side
generated proxy, you get some problem with the generated proxy class of the
DataTable return object, correct?
Based on my experience, as for WCF client-side proxy, if you contains
complex type in your WCF service side, it will automatically create a proxy
class corresponding to it(like a simple wrapper class that has the same
field/properties set). However, for those type such as Typed
dataset/datatable or collection types, you may need to reuse the same types
as what used in the WCF service methods. For example, you can define the
Typed dataset/datatable in a separate class library project, and both the
WCF service and client application(which contains the proxy) can reuse the
same type (in the class library assembly).
#Type sharing in WCF service reference
http://blogs.msdn.com/lifenglu/archive/2007/05/09/type-sharing-in-wcf-servic e-reference.aspx
#Sharing WCF Collection Types between Service and Client
http://www.codeproject.com/KB/WCF/WCFCollectionTypeSharing.aspx the above two reference has provided some guide on how to share/reuse types
between WCF service and client.
I have performed some tests on my side. Here is the steps to share the
DataTable types:
** create the DataTable in a separate class library project/assembly
** reference the DataTable class in both WCF service and client proxy
project
** and the most important part is the proxy generation. On my side, I use
VS 2008 which is quite simple to share type, since VS 2008 "Add Service
Reference" will be default reuse any types that are used in WCF service and
also referenced by the client-side project(which use the wcf proxy).
I noticed that you're using VS 2005, correct? Is there any VS 2008
available?(if so you can use it to help generate the proxy) Or as
mentioned in the above aritlce, you can also use 'svcutil.exe' to generate
proxy class which reuse existing types:
#ServiceModel Metadata Utility Tool (Svcutil.exe)
http://msdn.microsoft.com/en-us/library/aa347733.aspx this tool is available if you have .NET 3.0 and windows sdk 6 installed.
As document said, svcutil.exe use "/reference" command line option to let
you specify the assembly from which you want to share the types. thus, when
generating the proxy, if any types(used in the WCF service) is existing in
the specificed reference assembly, the proxy will reuse the type from the
assembly instead of creating a new wrapper class.
If you have anything unclear, please feel free to let me know.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx. ==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: =?Utf-8?B?UGF1bA==?= <Paul@discussions.microsoft.com>
Subject: WCF Client Generation Issue
Date: Fri, 9 May 2008 10:00:01 -0700
I apologize for the length of this message. I have tried to provide all of
the potentially relavant code up front to help identify the problem. I am
relatively new to WCF and hope that I have overlooked something relatively
simple.
I am currently developing a set of WCF (.NET 3.0) services to use as the
middle-tier of a distributed app. The services will not be publicly
available, and I have complete control over all three tiers of the
application.
Some of the services return strongly-typed DataTables for use by the UI
layer (ASP.NET 2.0) of the application. (SOA purists will object to this,
but we determined that this is the best choice for the data.) The
strongly-typed DataTables all follow the same model as the example listed
below.
The problem: I am using VisualStudio 2005 to generate a service reference
(client) class. I will be providing a wrapper class around the generated
client, compliant with my IComponentProviderListService, for consumers of
the
service to use. The generated interface includes the following comment:
"Parameter 'ListEquipmentResult' requires additional schema information
that
cannot be captured using the parameter mode." The specific attribute is
'System.Xml.Serialization.XmlElementAttribute'. What does this mean? How
do
I resolve it? In the generated ListEquipmentResponse and
ListEquipmentResponseListEquipmentResult classes (shown below), where am I
supposed to see something that looks like a serialized DataTable that I can
deserialize?
My interface looks like this:
[ServiceContract(SessionMode=SessionMode.Required)]
public interface IComponentProviderListService
{
. . .
[OperationContract(IsInitiating = false, IsTerminating = false)]
EquipmentList ListEquipment(bool availableOnly);
. . .
}
The analogous method in the proxy looks like
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel",
"3.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(ConfigurationName="ComponentSe
rvice.Proxy.ComponentProviderListService.IComponentProviderListService" +
"", SessionMode=System.ServiceModel.SessionMode.Required)]
public interface IComponentProviderListService
{
// CODEGEN: Parameter 'ListEquipmentResult' requires additional schema
information that cannot be captured using the parameter mode. The specific
attribute is 'System.Xml.Serialization.XmlElementAttribute'.
[System.ServiceModel.OperationContractAttribute(IsInitiating=false,
Action="
http://tempuri.org/IComponentProviderListService/ListEquipment",