WCF application Architecture?????
- Hi,
I am developing WCF windows application which is going to be stand alone application......
i have designed the architecture like this.
Main application--------------output willl windows application.
Client application------------output will be class lib project..which will have all UI design and forms n all.
ControlLib---------------------Containing all the controls and user controls.
WCF service application-----Here all the services....
Now i would like to know where should i keep the DataAccess layer class which will contain connection string etc n all????
i believe business logic will be implemented in services....
So should i keep the Data access layer class in WCF service application???? make that also service????
Basically i am new to WCF and i am trying to learn WCF through real time development...
So plz guide me how to go about it???
Thanks...
All Replies
- Hi,
First I haven't got a clear idea about the architecture. Can you give a brief explanantion about your project? like What is the Main App? What is it for? What is the Client App for? Is Control Lib common for both Main App and Client App?
If possible shall I get the solution explorer view?
If the application is pretty big, maintenance will be a matter in future. It is better to separate the busiess rules and data operations from WCF Service and make them as separate class libraries. So each of them Service, Business and DB stands in seprate layers.
What is the host for this WCF service? you haven't said about that. I suggest you better put things like below..
1. Main
2. Client
3. Entities (Class Library)
4. Busines Objects (Class Library)
5. Data Access (Class Library)
5. Services (Class Library - Contains the Contracts and Implemenations)
6. Hosts
Regards
Dnana
Hi,
Dnana has a point there, your design is a bit blurry. Regarding the DAL layer, the practice is to create it as a separate component (connection strings must be moved/referenced to/from a config file of the component using the DAL).
Regards,
John- Hi,
This is the architecture recommended by the Patterns & Practices team in Microsoft, http://msdn.microsoft.com/practices/guidetype/Guides/default.aspx?pull=/library/en-us/dnbda/html/distapp.asp
I do not think it is the best one, but it certainly should work for your scenario. In that architecture, WCF should part of the service interface.
Also, you might want to take a look at the P&P Web Service Service Factory (Modeling Edition), which provides wizards and assets to build an application following that architecture. http://msdn.microsoft.com/en-us/library/cc487895.aspx
Regards,
Pablo.
Pablo Cibraro - http://weblogs.asp.net/cibrax- Proposed As Answer byPablo CibraroMVPFriday, June 12, 2009 1:16 PM
- Unproposed As Answer byabhi0410 Sunday, June 14, 2009 4:04 AM
- Marked As Answer byBin-ze ZhaoMSFT, ModeratorTuesday, June 16, 2009 4:03 AM
- Unmarked As Answer byabhi0410 Tuesday, June 16, 2009 10:02 AM
- Hi all,
Thanks for you suggestion.i will go through the link is provided above. I need one favor if it is possible..Can anyone just make one test project( 1 form with one text box and button and combox) and tell me the flow then it would be great..
Because when i search on net, then i see the examples where they have defined Datacontract, service and implementation n all in one class lib...
But i believe that is nt right way..
So if possible then plz do send me the a test project with some code in the archi which Dnana has said..
thanks..
n in case anybody sending me the proejct then my email id--- abhi0410@gmail.com abhi0410,
I am going through a WCF learning curve myself. I am also learning Azure. So I have put the two together. Azure has a few work arounds needed but it is a super environment to work in locally. Plus you are learning the latest stuff, I suspect it will take off like a rocket, and if you don’t know it you will be left in the dust, my opinion .
I look at the best practice stuff and it puts me to sleep. I can’t learn without doing. I also can’t learn from someone else’s project, I don’t know how they created it. So, if you want to kill two birds with one stone, see the instructions below. If you can’t do what you want with this combo, then I don’t know what will do it!
You will need to Download the may Azure CTP, and have Visual Studio 2008. I have standard but if you don’t have it you can download professional for a 90 day trial, can’t beat it! Free high power development tools for nothing! Search the web for both, easy to find.
I wrote up the instructions as I created the solution, today after I read your post, I needed to do it for my own sanity check, so it should be accurate, but who knows. Post back if you have problems.
Dave
Open VS 2008, make sure you right click “run as admin” when you start, Azure need this.
I used all default project settings;
Create blank solution
Under cloud service, add new cloud web and worker cloud service project
Under windows Add windows form project.
Right click the webrole project, add new item, WPF service.
Open the IService1.cs and Service1svc.cs files
Change the do work in the files to so you can do something;
public string DoWork(string msg)
{
return msg + "WPF service hit!!!";
}
public interface IService1
{
[OperationContract]
string DoWork(string msg);
}
Change the WCF binding to get rid of the partial trust error.
In VS 2008, go to tools and open WCF Service Configuration Editor, close it.
Right click the webrole Web.config file and edit in the WCF service editor.
Expand Service, click CloudService1_WebRole.IService1, click End points, then the first (empty name),
Should be set at wsHttpBinding, change to basicHttpBinding, save close.
Make sure the cloud service1 is the startup project (right click and set as startup)
F5 start project, in the browser type in http://127.0.0.1:81/service1.svc, this should make sure the service is running. You will see the, Service1 Service, You have created a service. If you do you are good to go!
Stop debugging.
This is a little bit trickier, Azure has a disco bug, so if you were running the service and tried to add a reference, it would be wrong.
Right click your WindowsFormsApplication1 project, add service reference, discover, ok you will notice it will spin up the asp.net server and disco it with the wrong port. After this you can close the asp.net server (in the task bar)
So, now you have a reference created, modify the endpoint (recommended Azure work around). Open the WindowsFormsApplication1 app.config in notepad ( project not running) and change the endpoint address="http://localhost:51033/Service1.svc" binding="basicHttpBinding, to endpoint address="http://127.0.0.1:81/service1.svc" binding="basicHttpBinding, save close.
Add a button and click event handler, and text box to the WindowsFormsApplication1.
Add this to the button event handler, use you button and textbox names;
private void button1Clk(object sender, EventArgs e)
{
WindowsFormsApplication1.ServiceReference1.Service1Client testService = new WindowsFormsApplication1.ServiceReference1.Service1Client();
textBox1.Text = testService.DoWork("service call from winform ");
}
Right click the solution and set up multiple startup projects, set start cloud Service1, and then start WindowsFormsApplication1 so both are running, the cloud (local fabric) may take some time to spin up, so wait before clicking the button on you WindowsFormsApplication1.
Run the app (F5), you should get “service call from winform WPF service hit!!!” in the textbox. You are now an official WPF / Azure code cranker!
- Edited bydavgreen Saturday, June 13, 2009 9:00 PM
- Marked As Answer byBin-ze ZhaoMSFT, ModeratorTuesday, June 16, 2009 4:03 AM
- Unmarked As Answer byabhi0410 Tuesday, June 16, 2009 10:02 AM


