473,465 Members | 1,896 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Design help.

Hi, sorry for a crosspost but that other news group was showing last post was a
week ago so I guess it dosen't see much use...

I'm about to start a solution and I'm curious about the approach of a webservices project.
Should the objects be represented in classes such as...

public class Orders (ie Orders.cs) within a project
and then have the service be in a class like OrdersService.asmx
public class OrdersService : System.Web.Services.WebService
and this class contain only [WebMethod] 's

I guess another another way to ask the same question is..
Would it be less desireable if a class inheriting System.Web.Services.WebService
contain methods that are not [Web Method]


Nov 21 '06 #1
4 1315
You are on the correct path!
The better design approach is to declare your interfaces first.

1) Declare interfaces
2) Implement this interface in your classes (C# class).
3) Implemtent the webservices classes from the same interface
4) In the WS, authenticate and authorize access to the business logic
implemented in your "true" classes (step 2).

Why?
Well - first of all it forces you to take a contract-first approach. Next it
allows you to call the logic from another "client" than the webservice that
exposes the methods. Second it de-couples the businss from the fact that it
is exposed as a webservices; not really a businnss entiity, is it?

Example:

public interfaces IOrder
{
string GetSomething(arguments...);
}

public class Order : IOrder
{
//..
}

[WebService]
public class OrderService : WebService, IOrder
{

[WebMethod]
public string GetSomething((arguments..)
{
//authorize
//if not allowed access - throw UnAuthorizedAccessException!

//instantiate businnss logic

//return data
}

}

--
rgds.
/Claus Konrad
MCSD.NET (C#)
"John Sitka" wrote:
Hi, sorry for a crosspost but that other news group was showing last post was a
week ago so I guess it dosen't see much use...

I'm about to start a solution and I'm curious about the approach of a webservices project.
Should the objects be represented in classes such as...

public class Orders (ie Orders.cs) within a project
and then have the service be in a class like OrdersService.asmx
public class OrdersService : System.Web.Services.WebService
and this class contain only [WebMethod] 's

I guess another another way to ask the same question is..
Would it be less desireable if a class inheriting System.Web.Services.WebService
contain methods that are not [Web Method]


Nov 23 '06 #2
Thank you, I'm not skilled enough to understand though.

"Claus Konrad [MCSD]" <Cl*************@discussions.microsoft.comwrote in message
news:0E**********************************@microsof t.com...
You are on the correct path!
The better design approach is to declare your interfaces first.

1) Declare interfaces
2) Implement this interface in your classes (C# class).
3) Implemtent the webservices classes from the same interface
4) In the WS, authenticate and authorize access to the business logic
implemented in your "true" classes (step 2).

Why?
Well - first of all it forces you to take a contract-first approach. Next it
allows you to call the logic from another "client" than the webservice that
exposes the methods. Second it de-couples the businss from the fact that it
is exposed as a webservices; not really a businnss entiity, is it?

Example:

public interfaces IOrder
{
string GetSomething(arguments...);
}

public class Order : IOrder
{
//..
}

[WebService]
public class OrderService : WebService, IOrder
{

[WebMethod]
public string GetSomething((arguments..)
{
//authorize
//if not allowed access - throw UnAuthorizedAccessException!

//instantiate businnss logic

//return data
}

}

--
rgds.
/Claus Konrad
MCSD.NET (C#)
"John Sitka" wrote:
>Hi, sorry for a crosspost but that other news group was showing last post was a
week ago so I guess it dosen't see much use...

I'm about to start a solution and I'm curious about the approach of a webservices project.
Should the objects be represented in classes such as...

public class Orders (ie Orders.cs) within a project
and then have the service be in a class like OrdersService.asmx
public class OrdersService : System.Web.Services.WebService
and this class contain only [WebMethod] 's

I guess another another way to ask the same question is..
Would it be less desireable if a class inheriting System.Web.Services.WebService
contain methods that are not [Web Method]



Nov 24 '06 #3
Fair enough.

In that case: It is best practice NOT to implement business logic directly
in the WebService methods. Do this in dedicated dll's (assemblies).

Let the webservice methods expose this logic to the "world", no more.
It is the job of the webservice to decide whether clients are allowed to use
the logic though, hence let the webservice authorize access or not to the
business logic.

If allowed access - instantiate the business logic and delegate the call to
these components.

Is this more clear?
--
rgds.
/Claus Konrad
MCSD.NET (C#)
"John Sitka" wrote:
Thank you, I'm not skilled enough to understand though.

"Claus Konrad [MCSD]" <Cl*************@discussions.microsoft.comwrote in message
news:0E**********************************@microsof t.com...
You are on the correct path!
The better design approach is to declare your interfaces first.

1) Declare interfaces
2) Implement this interface in your classes (C# class).
3) Implemtent the webservices classes from the same interface
4) In the WS, authenticate and authorize access to the business logic
implemented in your "true" classes (step 2).

Why?
Well - first of all it forces you to take a contract-first approach. Next it
allows you to call the logic from another "client" than the webservice that
exposes the methods. Second it de-couples the businss from the fact that it
is exposed as a webservices; not really a businnss entiity, is it?

Example:

public interfaces IOrder
{
string GetSomething(arguments...);
}

public class Order : IOrder
{
//..
}

[WebService]
public class OrderService : WebService, IOrder
{

[WebMethod]
public string GetSomething((arguments..)
{
//authorize
//if not allowed access - throw UnAuthorizedAccessException!

//instantiate businnss logic

//return data
}

}

--
rgds.
/Claus Konrad
MCSD.NET (C#)
"John Sitka" wrote:
Hi, sorry for a crosspost but that other news group was showing last post was a
week ago so I guess it dosen't see much use...

I'm about to start a solution and I'm curious about the approach of a webservices project.
Should the objects be represented in classes such as...

public class Orders (ie Orders.cs) within a project
and then have the service be in a class like OrdersService.asmx
public class OrdersService : System.Web.Services.WebService
and this class contain only [WebMethod] 's

I guess another another way to ask the same question is..
Would it be less desireable if a class inheriting System.Web.Services.WebService
contain methods that are not [Web Method]




Nov 24 '06 #4
Yes, I think I kind of froze up when you mentioned contract first, I started having visions
of having to maintain the WSDL in notepad. The more I tried to understand the more I realized
I'm not at that level yet. Really the original question was derived after looking at some sample code,
I thought to myself, Since all the webservice is doing is relfecting the methods why would
I put any business logic in the .asmx code. At least that instinct, while probably not absolutely
true in all cases, was kind of correct.
Thanks

"Claus Konrad [MCSD]" <Cl*************@discussions.microsoft.comwrote in message
news:88**********************************@microsof t.com...
Fair enough.

In that case: It is best practice NOT to implement business logic directly
in the WebService methods. Do this in dedicated dll's (assemblies).

Let the webservice methods expose this logic to the "world", no more.
It is the job of the webservice to decide whether clients are allowed to use
the logic though, hence let the webservice authorize access or not to the
business logic.

If allowed access - instantiate the business logic and delegate the call to
these components.

Is this more clear?
--
rgds.
/Claus Konrad
MCSD.NET (C#)
"John Sitka" wrote:
>Thank you, I'm not skilled enough to understand though.

"Claus Konrad [MCSD]" <Cl*************@discussions.microsoft.comwrote in message
news:0E**********************************@microso ft.com...
You are on the correct path!
The better design approach is to declare your interfaces first.

1) Declare interfaces
2) Implement this interface in your classes (C# class).
3) Implemtent the webservices classes from the same interface
4) In the WS, authenticate and authorize access to the business logic
implemented in your "true" classes (step 2).

Why?
Well - first of all it forces you to take a contract-first approach. Next it
allows you to call the logic from another "client" than the webservice that
exposes the methods. Second it de-couples the businss from the fact that it
is exposed as a webservices; not really a businnss entiity, is it?

Example:

public interfaces IOrder
{
string GetSomething(arguments...);
}

public class Order : IOrder
{
//..
}

[WebService]
public class OrderService : WebService, IOrder
{

[WebMethod]
public string GetSomething((arguments..)
{
//authorize
//if not allowed access - throw UnAuthorizedAccessException!

//instantiate businnss logic

//return data
}

}

--
rgds.
/Claus Konrad
MCSD.NET (C#)
"John Sitka" wrote:

Hi, sorry for a crosspost but that other news group was showing last post was a
week ago so I guess it dosen't see much use...

I'm about to start a solution and I'm curious about the approach of a webservices project.
Should the objects be represented in classes such as...

public class Orders (ie Orders.cs) within a project
and then have the service be in a class like OrdersService.asmx
public class OrdersService : System.Web.Services.WebService
and this class contain only [WebMethod] 's

I guess another another way to ask the same question is..
Would it be less desireable if a class inheriting System.Web.Services.WebService
contain methods that are not [Web Method]





Nov 27 '06 #5

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

Similar topics

36
by: Andrea Griffini | last post by:
I did it. I proposed python as the main language for our next CAD/CAM software because I think that it has all the potential needed for it. I'm not sure yet if the decision will get through, but...
3
by: Rushikesh | last post by:
I am designing a WEB BASED Accounting Software with ASP and SQL Server. For this I need some help for the Database design. My design is as follows. I)User table: User_id, UserName..... Users...
7
by: Bora Eryilmaz | last post by:
I am working on designing a set of abstract classes that would be subclassed by the users and they have to implement the abtract (virtual) methods. Does anybody know of a good reference on...
9
by: sk | last post by:
I have an applicaton in which I collect data for different parameters for a set of devices. The data are entered into a single table, each set of name, value pairs time-stamped and associated with...
7
by: Shimon Sim | last post by:
I have a custom composite control I have following property
20
by: Brad Pears | last post by:
I am completely new to vb .net. I am using visual Studio 2005 to redo an Access 2000 application into a .net OO application using SQL Server 2000 - so a complete rewrite and re-thinking of how...
0
by: YellowFin Announcements | last post by:
Introduction Usability and relevance have been identified as the major factors preventing mass adoption of Business Intelligence applications. What we have today are traditional BI tools that...
9
by: Grizlyk | last post by:
Somebody have offered std colors to C++ in the msg here: http://groups.google.com/group/comp.lang.c++/browse_frm/thread/2e5bb3d36ece543b/1acf6cd7e3ebdbcd#1acf6cd7e3ebdbcd The main objection to...
9
by: AceKnocks | last post by:
I am working on a framework design problem in which I have to design a C++ based framework capable of solving three puzzles for now but actually it should work with a general puzzle of any kind and I...
4
by: Ken Fine | last post by:
I've been living with a frustrating issue with VS.NET for some months now and I need to figure out what the problem is. Hopefully someone has run into the same issue and can suggest a fix. I...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.