473,385 Members | 2,028 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,385 software developers and data experts.

WCF, Typed Datasets and DataContracts

Hi,

I'm new to this WCF world, and have attempted to create a WCF service
which takes a typed dataset as its data contract. I know this isn't
always put forward for interopability, but I'm working in a pure .Net
environment (.Net 3.0) and VS2005.

However, how do I get the client to populate this data object to send
into the WCF service? After I generate the proxy class using svcutil
and do;

TypedDataSet ds = new TypedDataSet();

The 'ds' object isn't what I'd expect from a dataset! So how'd I get
data into it?!??!

Sorry if vague...

Alternatively any good web sites on WCF and data contracts?

Cheers
Jun 27 '08 #1
4 5504
If you are working in pure .NET, and have control of both ends (and
are just uwing WCF as a comms layer, rather than an interopability
layer), then a sensible option is assembly sharing; put your contracts
(service and data) into a single assembly, and reference that assembly
from both the service (often running in IIS) and the client (generally
an exe). Now you don't need to use svcutil at all! You just configure
the endpoint in the config file, and use it. Both ends have exactly
the same interpretation of what the data is, and it "just works".

This also means you can have sensible business logic in your entity at
the client, rather than just the raw proxy.

Marc
Jun 27 '08 #2
I forgot to say... to represent the service, you can subclass
ClientBase<T(which is what svcutil does); but using generics you
only have to do it once (obviously you need to add some other ctors
etc if you want to use non-default endpoints):
public sealed class WcfClient<T: System.ServiceModel.ClientBase<T>,
IDisposable where T : class
{
void IDisposable.Dispose() { Dispose(); } // re-implement dispose
public void Dispose()
{
try
{// faulted state is poorly implemented by MS, and blocks
Close() and Dispose()!
switch (State)
{
case CommunicationState.Opened:
case CommunicationState.Opening:
Close(); break;
case CommunicationState.Faulted:
Abort(); break;
}
}
catch { }
}
public T Service
{
get { return base.Channel; }
}
}
[ServiceContract]
interface IFoo
{
[OperationContract]
void Bar();
}
static class Program {
static void Main()
{
// use our WCF service
using (WcfClient<IFooclient = new WcfClient<IFoo>())
{
client.Service.Bar();
}
}
}
Jun 27 '08 #3
On Apr 24, 10:02 am, Marc Gravell <marc.grav...@gmail.comwrote:
I forgot to say... to represent the service, you can subclass
ClientBase<T(which is what svcutil does); but using generics you
only have to do it once (obviously you need to add some other ctors
etc if you want to use non-default endpoints):

public sealed class WcfClient<T: System.ServiceModel.ClientBase<T>,
IDisposable where T : class
{
void IDisposable.Dispose() { Dispose(); } // re-implement dispose
public void Dispose()
{
try
{// faulted state is poorly implemented by MS, and blocks
Close() and Dispose()!
switch (State)
{
case CommunicationState.Opened:
case CommunicationState.Opening:
Close(); break;
case CommunicationState.Faulted:
Abort(); break;
}
}
catch { }
}
public T Service
{
get { return base.Channel; }
}}

[ServiceContract]
interface IFoo
{
[OperationContract]
void Bar();}

static class Program {
static void Main()
{
// use our WCF service
using (WcfClient<IFooclient = new WcfClient<IFoo>())
{
client.Service.Bar();
}
}

}
Marc,

Many thanks this is exactly what I was looking for, it works a
treat.

Cheers
Mat
Jun 27 '08 #4
You can take a look here as well:

http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!158.entry

WCF with Interface Development
If you want to stick with strong datasets, that would work with the above
setup as well.

<ma*************@ntlworld.comwrote in message
news:cd**********************************@34g2000h sf.googlegroups.com...
Hi,

I'm new to this WCF world, and have attempted to create a WCF service
which takes a typed dataset as its data contract. I know this isn't
always put forward for interopability, but I'm working in a pure .Net
environment (.Net 3.0) and VS2005.

However, how do I get the client to populate this data object to send
into the WCF service? After I generate the proxy class using svcutil
and do;

TypedDataSet ds = new TypedDataSet();

The 'ds' object isn't what I'd expect from a dataset! So how'd I get
data into it?!??!

Sorry if vague...

Alternatively any good web sites on WCF and data contracts?

Cheers

Jun 27 '08 #5

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

Similar topics

0
by: Natehop | last post by:
I've been attempting to design an n-tiered framework leveraging .NET's strongly typed Dataset. My Framework will serve as the foundation to several client apps from Windows applications to web...
2
by: Freed Flinstone | last post by:
Why after adding a dll (with dataset schemas) to my project I can access and use my the typed datasets, then for no reason say 5mins later I can no longer fully access them. The inteliSence goes from...
0
by: Bj?rn Mor?n | last post by:
I am consuming a web service that returns arrays of classes which can contain other classes (a hierarchy of data). Is there a simple way to move the data into a typed DataSet without writing too...
7
by: Tim Smith | last post by:
Hi, Is it possible to create a progam to mimic the following action a) drag oledbadapter to form1.cs b) select my oracle ole connection c) enter 'select * from mytable' d) create adapter for...
3
by: Rob Thomas | last post by:
Hi, I've been tasked to come up with a new architecture for a large application at one of my customer's sites. In the past, I have developed multi-tier applications whereby the business...
3
by: Mike | last post by:
Hi, I'm delevloping a webservice that returns typed datasets with visual studio 2005. The problem is, that the typed data set in the client app is not the same as in the webservice. If I change...
21
by: Peter Bradley | last post by:
Hi all, This post is sort of tangentially related to my earlier posts on configuration files for DLLs. Does anyone know how to create typed DataSets using VS2005's new DataSet designer, but...
4
by: newtonwong | last post by:
I have a web reference WSDL, but it doesn't really create an XSD. I'm trying to generate datasets from the WSDL file but not sure how to do so. I successfully created the proxy class, but the...
4
by: Rachana | last post by:
Hi, I have understood Data Sets but what is meant by typed/untyped/ strongly typed datasets. Can any one explain me or suggest any site/ article, to get these concepts (and their ...
12
by: BillE | last post by:
I'm trying to decide if it is better to use typed datasets or business objects, so I would appreciate any thoughts from someone with more experience. When I use a business object to populate a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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.