Web Service App design opinions

P

PaulMac

I would like to hear opinions on Web Service App design in terms of where
different developers have placed certain initialization or database
connection code. For example, say we have a Web Service that uses ADO.NET
to connect to a database. Where do you prefer to place the code to connect
and disconnect? Each Web Method? A "global" area like the Web Service
class constructor and destructors (Dispose)? How about somewhere in
Global.ASAX? What if not all Web Methods needed the database connection?
What is optimal in that case?

I'll also add to this discussion that the garbage collection and/or
connection pooling has been an issue for me. There have been problems where
the database engine resource governor has throw an exception. Therefore,
resources need to be released as soon as possible. I cannot follow the
numerous .NET programming examples where objects and connections are made
and aren't explicitly freed (allow the automatic mechanism to clean up).

Paul
 
N

Nathan

I would look at not doing any of this in the WS, but
instead creating a seperate object that handles this. I
would just have the WS use that object and be completely
oblivious to those details.

This will make unit testing much simpler as well as the
object can be reused, i.e., not just in a WS. I think the
seperation makes the design a bit more reusable and less
coupled.

my 2 cents.

Nathan
 
Y

Yan-Hong Huang[MSFT]

Hello Paul,

Thanks for posting in the group.

Data access is a hot topic in .net programming. We often meet questions
like "when to release connection", "where to store connection string" and
etc. In MSDN, there are many good articles in this area. Here are some that
I recommend to you:

".NET Data Access Architecture Guide"
http://msdn.microsoft.com/library/en-us/dnbda/html/daag.asp?frame=true
This document provides guidance to help you choose the most appropriate
data access approach. It does so by detailing a wide range of common data
access scenarios, providing performance tips, and prescribing best
practices. This document also provides answers to other frequently asked
questions: Where's the best place to store database connection strings? How
should I implement connection pooling? How should I work with transactions?
How should I implement paging to allow users to scroll through large
numbers of records?

"Best Practices for Using ADO.NET"
http://msdn.microsoft.com/library/en-us/dnadonet/html/adonetbest.asp?frame=t
rue
This article provides you with the best solutions for implementing and
achieving optimal performance, scalability, and functionality in your
Microsoft ADO.NET applications; it also covers best practices when using
objects available in ADO.NET and offers suggestions that can help you
optimize the design of your ADO.NET application.

The same principles apply to asp.net web service applications also.

Hope that helps.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!From: "PaulMac" <[email protected]>
!Subject: Web Service App design opinions
!Date: Wed, 1 Oct 2003 11:13:28 -0400
!Lines: 19
!X-Priority: 3
!X-MSMail-Priority: Normal
!X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
!X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
!Message-ID: <#[email protected]>
!Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
!NNTP-Posting-Host: 65.162.128.158
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
!Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet.webservices:19654
!X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
!
!I would like to hear opinions on Web Service App design in terms of where
!different developers have placed certain initialization or database
!connection code. For example, say we have a Web Service that uses ADO.NET
!to connect to a database. Where do you prefer to place the code to connect
!and disconnect? Each Web Method? A "global" area like the Web Service
!class constructor and destructors (Dispose)? How about somewhere in
!Global.ASAX? What if not all Web Methods needed the database connection?
!What is optimal in that case?
!
!I'll also add to this discussion that the garbage collection and/or
!connection pooling has been an issue for me. There have been problems
where
!the database engine resource governor has throw an exception. Therefore,
!resources need to be released as soon as possible. I cannot follow the
!numerous .NET programming examples where objects and connections are made
!and aren't explicitly freed (allow the automatic mechanism to clean up).
!
!Paul
!
!
!
 
P

PaulMac

Hi Yanhong,

Thank you for the link to that excellent information. It answers a lot of
questions.

Paul Mac
 
Y

Yan-Hong Huang[MSFT]

Hi Paul,

It is my pleasure. :)

Thanks for participating the community.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!From: "PaulMac" <[email protected]>
!References: <#[email protected]>
<[email protected]>
!Subject: Re: Web Service App design opinions
!Date: Thu, 2 Oct 2003 09:13:09 -0400
!Lines: 52
!X-Priority: 3
!X-MSMail-Priority: Normal
!X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
!X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
!Message-ID: <[email protected]>
!Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
!NNTP-Posting-Host: 65.162.128.158
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
!Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.aspnet.webservices:19686
!X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
!
!Hi Yanhong,
!
!Thank you for the link to that excellent information. It answers a lot of
!questions.
!
!Paul Mac
!
!
!!> Hello Paul,
!>
!> Thanks for posting in the group.
!>
!> Data access is a hot topic in .net programming. We often meet questions
!> like "when to release connection", "where to store connection string" and
!> etc. In MSDN, there are many good articles in this area. Here are some
!that
!> I recommend to you:
!>
!> ".NET Data Access Architecture Guide"
!> http://msdn.microsoft.com/library/en-us/dnbda/html/daag.asp?frame=true
!> This document provides guidance to help you choose the most appropriate
!> data access approach. It does so by detailing a wide range of common data
!> access scenarios, providing performance tips, and prescribing best
!> practices. This document also provides answers to other frequently asked
!> questions: Where's the best place to store database connection strings?
!How
!> should I implement connection pooling? How should I work with
!transactions?
!> How should I implement paging to allow users to scroll through large
!> numbers of records?
!>
!> "Best Practices for Using ADO.NET"
!>
!http://msdn.microsoft.com/library/en-us/dnadonet/html/adonetbest.asp?frame=
t
!> rue
!> This article provides you with the best solutions for implementing and
!> achieving optimal performance, scalability, and functionality in your
!> Microsoft ADO.NET applications; it also covers best practices when using
!> objects available in ADO.NET and offers suggestions that can help you
!> optimize the design of your ADO.NET application.
!>
!> The same principles apply to asp.net web service applications also.
!>
!> Hope that helps.
!>
!> Best regards,
!> Yanhong Huang
!> Microsoft Online Partner Support
!
!
!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top