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 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
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();
}
}
}
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
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
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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 ...
|
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...
|
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,...
|
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$) {
}
...
|
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...
|
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
|
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...
|
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...
|
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...
|
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,...
|
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...
| | |