What is Self Hosting?
WCF allows hosting a service in an application such as Console Application.
- Create a Console Application Project to host a WCF Service.
- Add WCF Service project Reference in this Console Application.
- Delete existing App.config file.
- Add new App.config file.
- Rightclick on App.Config and select Edit WCF Configuration.
7. Browse for Bin->Debug location (Make sure you have built the console application successfully.)
14. Click on Add and select serviceMetaData
15. Select serviceMetaData from left side and set HttpGetEnabled to True.
16. Select Service name from left side and select BehaviorConfiguration from drop down. Refer highlighted section in below screen.
17. Now close the WCF Config Editor, and it will prompt to save. Save it.
18. Now your new App.Config file will look like this.
19. Now write code in Program.cs
Now remember this is your service url:
20. Now create a client to consume this WCF service. Add a service reference.
22. The host is running now; let’s try to add service reference once again.
23. Now you can see, service was found.
24. Change the namespace to WCFSelfServiceRef and write below code.
25. Execute the code and you will see the output like below.
- Introduction to WCF
- ABC of WCF
- Basics of WCF Architecture
- WCF vs Web Service
- What is XML serialization?
- WCF Binding
- Create first WCF application
- Fault Contract in
- WCF Data Contract vs Message Contract
- Message Contract
- Data Contract Serialization and De-Serialization
- Data Contract in WCF
- Operation Contract in WCF
- Service Contract in WCF
- How to host a WCF service in IIS?
- WAS Hosting in WCF
- Self Hosting in WCF
- How to create WCF RESTful Service.