473,322 Members | 1,431 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,322 software developers and data experts.

Setting up a "data contract" in .NET 2.0

Hello everyone!

I have been looking for information regarding the SOA tenet of
decoupling the client interface from the web service interface. I
understand the value of not sharing a contract based on a class type;
instead, a contract based on the data is what we should be
implementing. However, information on how to properly implement this
in .NET 2.0 is pretty scarce.

I have been fiddling around with a simple web-service and client I
created just to test this idea. On the web-service side I have a
simple HelloWorld method that returns a new instance of the following
type :

public class WebService.Test
{
// data I would like to include in the contract
public string FirstName = "Hello";
public string LastName = "World";

// other data and methods I do not want in the contract
...
}

As you can see from the above comments the only data that needs to be
passed to the client are the FirstName and LastName fields; I do not
want the other data and methods to be passed/implemented on the client
side.

On the client side, I have the following Test class defined (very
simple and short for brevity) :

public class Client.Test
{
private string FirstName;
private string LastName;

public override string ToString()
{
return FirstName + " " + LastName;
}
}

As you already know, I can't cast the result of the web-method call to
the client-side version of Test. So the million dollar question is :
what is the best way to accomplish this?

On the client side I can update the web-reference and generate two
files : Reference.cs and Test.datasource. The Reference.cs file
contains the definition for the Test class which includes metadata for
the other data and methods that I do not want. I can, of course,
simply trim this automagically created Test class down to size (just
keep the FirstName and LastName fields) and implement whatever client-
side logic I want but it seems that every time you update the web-
reference you have to re-implement the code all over again since it
gets overwritten.

Would anyone point me in the right direction, maybe a few links or
excellent books? There must be a design pattern for this. I notice
that there's a DataContract attribute in .NET 3.0 but I'm limited to
the .NET 2.0 framework for now.

Regards,

Anthony

May 9 '07 #1
0 1737

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

Similar topics

0
by: Yi | last post by:
Hi, I am a scientist and new to .NET programming. On my PC, I am using Windows 2000 professional with IIS, SQL Server 2000 (standard, personal), Visual Basic .net (2003, standard). By following...
2
by: hch | last post by:
dataAdapter.Update(data, "TableName") won’t work! I was about to deploy my first website on the Internet only to discover that the dataAdapter.Update() throws the Server Error in the third...
3
by: 21novembre | last post by:
Hi all, I made a question several days before to describe my strange trouble of mysqldump. But I still can't figour it out. Well, I just want to ask another question whether I could just backup...
6
by: Jon Davis | last post by:
I recently learned how to do an <OBJECT> alternative to <IFRAME> in current browsers using: <object id="extendedhtml" type="text/html" data="otherpage.html" width="250" height="400"></object> ...
6
by: alederer | last post by:
Hallo! I have a table tstest(ts char(13) for bit data constraint a unique). This column is filled in a trigger with generate_unique(). In a application (CLI), I have the values of this...
8
by: Jerry | last post by:
I have an off-the-shelf app that uses an Access database as its backend. One of the tables contains a field with an "OLE Object" datatype. I'm writing some reports against this database, and I...
7
by: Alex Maghen | last post by:
Hi. I had previously installed VS2005 beta 1. I carefully followed all the steps (I thought) to deinstall it and then installed beta 2. According to the documentation, the "Data" directory which...
3
by: Mejmeyster | last post by:
Hi Everyone, I have a table in which one of the text fields has become too small (since it only holds 255 characters). To remedy that, I'm trying to change the data type of that field to "memo"...
3
by: BobRoyAce | last post by:
I am using Visual Studio 2008 w/ VB.NET. For the database, I am using SQL Server 2005, which is running on a dedicated server box. I am creating a WinForms application for a client. It is run...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.