Content by Category
.NET 1.x
.NET 2.0
.NET 3.0
.NET 3.5
.NET 4.0
.NET 4.5
.NET Assemblies
.NET Framework
.NET Getting Started
Accessibility
ADO.NET
Advertorials
Agile Development
AJAX
Amazon Web Services
Analysis Services
Android
Architecture
Arduino
ASP .NET Web API
ASP.NET
ASP.NET MVC
ASP.NET WebForms
Azure
B2B (Business Integration)
BDD
Big Data
Bing
BizTalk
Book Excerpts
Build and Deploy
Business Intelligence
C#
C++
ClickOnce
Cloud Computing
Code Contracts
CODE Framework Info - non Technical
CODE on the Road!
COM+
Community
Conferences
Continuous Integration
Crystal Reports
CSLA.NET
CSS
Data
Debugger
Design Patterns
Development Process
Display Technologies
Distributed Computing
Document Database
DotNetNuke
DSL
Dynamic Languages
Dynamic Programming
Editorials
Enterprise Services ("COM+")
Entity Framework
Events
Expression Blend
F#
Fox to Fox
Frameworks
Functional Programming
Git
Graphics
HTML 5
Internet Explorer 8.0
Interviews
IOS
iPhone
Iron Ruby
Java
Java Script
JavaScript
jQuery
JSON
Lightswitch
LINQ
Linux
LUA
Mac OS X
MDX
Messaging
Metro
Microsoft Application Blocks
Microsoft Business Rules Framework
Microsoft Dynamics
Microsoft Expression
Microsoft Office
Mobile Development
Mobile PC
Mono
MsBuild
MVVM
MySQL
Network
NHibernate
node.js
NOSQL
Nuget
Object Oriented Development
Objective C
Odata
OLAP
Open Source
Opinion
Opinions
Oracle
ORM
Other Languages
Parallel Programming
Patterns
PHP
Podcasts
Post Mortem
PowerPoint
Print/Output
Prism
Product News
Product Reviews
Project Management
Prolog
Python
Q&A
Rails
Rake
Razor
Reporting Services
REST
RIA Services
Ruby
Ruby on Rails
Scheme
Search
Security
Services
SharePoint
SignalR
Silverlight
SOA
Social Networks
Software & Law
Software Business
Source Control
Speech-Enabled Applications
SQL Server
SQL Server 2000
SQL Server 2005
SQL Server 2008
SQL Server 2012
SQL Server CE/AnyWhere/Mobile/Compact
SSIS
Subversion
Sync Framework
Tablet PC
TDD
Team System
Techniques
Testing and Quality Control
TFS
Tips
TypeScript
UI Design
UML
User Groups
VB Script
VB.NET
Version Control
VFP and .NET
VFP and SQL Server
Virtual Earth
Vista
Visual Basic
Visual Basic 6 (and older)
Visual FoxPro
Visual Studio .NET
Visual Studio 11
Visual Studio 2005
Visual Studio 2008
Visual Studio 2010
Visual Studio 2011
Visual Studio 2012
Visual Studio Tools for Office
VSX
WCF
Web Development (general)
Web Services
WebMatrix
WF
Whitepapers
Windows 7
Windows 8
Windows Azure
Windows Live
Windows Phone 7
Windows Phone SDK
Windows Server
Windows Vista
WinForms
WinRT
Workflow
WPF
XAML
Xiine Documentation
XML
XNA
XSLT



Learn Now


rssbus
 


Xojo

Reader rating:
Click here to read 43 comments about this article.
Article source: CoDe (2008 Sep/Oct)


Article Pages:  1  2 3 4 5 - Next >


WCF the Manual Way… the Right Way

Visual Studio 2008 as well as the .NET 3.0 extensions for Visual Studio 2005 add several new templates that allow you to quickly create .NET 3.0 items such as WPF forms, Workflows, and WCF services. We’ve used templates such as these since the beginning of time to create traditional application elements such as Windows Forms, Web Forms, and User Controls, so you would think that these are equally great; or would you? Unfortunately, creating WCF projects or project items come with more baggage than you can imagine. They also don’t exactly promote the best practices I feel should be considered when designing WCF services. So if you don’t use the built-in templates to create your services, what do you use? Well keep reading and I’ll show you how to create everything you need manually with ease while maintaining good design and coding practices.

Sometimes, when tools do a lot of work for you, the results may not exactly be the best. In my humble opinion, such is the case with WCF. Now, let me start by saying that WCF is probably one of the absolutely coolest technologies to come out of Microsoft. I think the unified model toward developing message-based applications and service-oriented applications is long overdue in our industry, and I’m glad to see that it came from Microsoft. That being said, I’m not too crazy about the templates that come with Visual Studio 2008 or the 3.0 extensions for Visual Studio 2005. I feel Microsoft could have done a better job toward code separation and the enforcement of good practices; never mind best practices.

Another area where I see developers doing things automatically and falling a bit short is in referencing services from client application. When developers used mainly Web services, the choices were more limited but such is no longer the case. Adding service references automatically may not be the best way to write service consumers.

Fortunately you can easily solve these problems by creating all your service components manually and it’s not even that hard to do.

I don’t want to come across as overly critical or make this sound like a bashing session, because it is definitely not. I merely want to point out a few shortcomings and show you how to overcome them. In doing so, I think you will get a good understanding on how the individual pieces of WCF-based applications work and fit together as well as my recommended assembly separation for WCF-based applications.

I also want to mention that this article assumes some basic knowledge of WCF services and the elements that comprise them. Not too much, just a bit.

So what Exactly Is Wrong?

Anyone who knows me knows that I love getting into political conversations with friends and otherwise (sometimes friends become otherwise because of this); and one of my pet peeves is when politicians criticize and destroy current policy without offering a better solution of how things should be done. Well I won’t fall into the very practices I despise. Instead, I will tell you exactly what I feel is wrong with the WCF-related project and item templates that come with Visual Studio, and then I’ll tell you how I think you can overcome these problems. So look out Congress! Here I come.

The current WCF templates in Visual Studio as well as the Add Service Reference tool suffer from one major problem: they do too much. I think developers would have benefited a lot more from many templates that do less, instead of a few that do a lot. Creating service items automatically create both the contract and the service; two things that should be in separate projects (for reasons I will explain later). Creating service web projects also creates these two items as well as the service host; which I also feel should be its own assembly. Both situations also contribute to the configuration file. While this is good for educational purposes, it can also clutter up an existing clean configuration file. Templates that I feel are missing include ones for individually creating all these elements. In addition, I’d like to see a project template to create a self-host project that’s not IIS-based. As far as the Add Service Reference tool, it also creates too much for you and does not promote good code reuse. Not only does it create proxies for you, but it adds an immense amount of configuration information.

To illustrate what I mean, I’ll walk you through using the WCF templates and tools in order to develop a simple service and client. I’ll later analyze what I see wrong with the results and provide alternatives.

&

By: Miguel Castro

Miguel is an architect with IDesign who specializes in architecture consulting and building .NET solutions. He is a Microsoft MVP and INETA speaker and has been a software developer for over 22 years. With a Microsoft background that goes all the way back to VB 1.0 (and QuickBasic in fact), Miguel jumped on .NET as soon as the first public Beta was released and has provided .NET solutions for clients around the country in a variety of industries. He considers himself to be a .NET Developer and Architect and has equal love for both VB and C#, and no tolerance for language bigotry. He’s spoken at numerous user groups around the country as well as developer conferences.

He’s the author of the CodeBreeze code-generator, which among things can be found on his Web site:

www.steelbluesolutions.com

Miguel currently lives in Lincoln Park, NJ with his wife Elena and his daughter Victoria.

subscriptions@infotekcg.com

Fast Facts

Service orientation is not a replacement for object orientation or component orientation. Just like component-oriented architectures build on the principles of object-oriented programming, service-oriented designs use concepts of component design and bring other concepts on top of that.



Article Pages:  1  2 3 4 5 - Next Page: 'The “Before”' >>

Page 1: WCF the Manual Way… the Right Way
Page 2: The “Before”
Page 3: Consuming the Service
Page 4: Concepts Applied
Page 5: The Consumer Side

How would you rate the quality of this article?
1 2 3 4 5
Poor      Outstanding

Tell us why you rated the content this way. (optional)

Average rating:
4.5 out of 5

164 people have rated this article.

Xojo

      AppsWorld Europe

 

Xojo