Both client and host are Asp.net's WCF Service Systems.

Source: Internet
Author: User

 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.