Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do SOA developers usually structure their Web Services (WCF) solutions in Visual Studio?

Tags:

c#

soa

wcf

I am in the initial stages of working on the design for an application. There will be the following:

  • Web interface
  • Web Service
  • Leveraging other pre-existing web service

I am new to windows services and SOA especially in the context of Visual Studio.

My question is, how would I set this solution up in Visual Studio? For example, would I

  • Put the web UI and service call in the same project, and put my service in a separate project and then put all of the above in a solution?

What is the best way to begin structuring my solution so that it can be traceable and tested?

like image 558
Nuri Aishe Avatar asked Feb 21 '23 14:02

Nuri Aishe


1 Answers

I like to structure my WCF solutions like this:

Contracts (class library)
Contains all the service, operations, fault, and data contracts. Can be shared between server and client in a pure .NET-to-.NET scenario

Service implementation (class library)
Contains the code to implement the services, and any support/helper methods needed to achieve this. Nothing else.

Service host(s) (optional - can be Winforms, Console App, NT Service)
Contains service host(s) for debugging/testing, or possibly also for production.

This basically gives me the server-side of things.

On the client side:

Client proxies (class library)
I like to package my client proxies into a separate class library, so that they can be reused by multiple actual client apps. This can be done using svcutil or "Add Service Reference" and manually tweaking the resulting horrible app.config's, or by doing manual implementation of client proxies (when sharing the contracts assembly) using ClientBase<T> or ChannelFactory<T> constructs.

1-n actual clients (any type of app)
Will typically only reference the client proxies assembly, or maybe the contracts assembly, too, if it's being shared. This can be ASP.NET, WPF, Winforms, console app, other services - you name it.

That way; I have a nice and clean layout, I use it consistently over and over again, and I really think this has made my code cleaner and easier to maintain.

This was inspired by Miguel Castro's Extreme WCF screen cast on DotNet Rocks TV with Carl Franklin - highly recommended screen cast !

like image 165
marc_s Avatar answered May 08 '23 10:05

marc_s