Both client and host are Asp.net's WCF Service Systems.
In this article, the WCF Service is hosted by IIS and the client is also an Asp.net application. In fact, this is just a special implementation method of WCF, that is, both client and host are Asp.net.
Like other WCF systems, it consists of three parts: Service, host, and client ).
I. Services and hosts
1. In vs2008, create an Asp.net Website: wcfserver.
2. Add a new WCF Service: servicewcf to the wcfserver project. In fact, you can also directly create a WCF Service website.
3. Add an operation in servicewcf: onhello () to return "Hello world !!"
Using system; using system. collections. generic; using system. LINQ; using system. runtime. serialization; using system. servicemodel; using system. text; public class servicewcf: iservicewcf {Public String onhello () {return "Hello world !! ";}}
4. Publish a website
Create a virtual directory in IIS and publish the website. That is, the WCF Service is hosted by IIS.
Ii. Client
1. Create an Asp.net Website: webajax and add a textbox and a button control to default. aspx.
2. Add "service reference" to webajax ".
3. Create a client proxy and call the operation of the WCF Service.
Using system; using system. configuration; using system. data; using system. LINQ; using system. web; using system. web. security; using system. web. ui; using system. web. UI. htmlcontrols; using system. web. UI. webcontrols; using system. web. UI. webcontrols. webparts; using system. XML. LINQ; public partial class _ default: system. web. UI. page {protected void page_load (Object sender, eventargs e) {} protected void button#click (Object sender, eventargs e) {expose client = new servicereference1.servicewcfclient (); string MSG = client. onhello (); this. textbox1.text = MSG ;}}
TextCode: Http://download.csdn.net/source/540466