Step by Step to create a WCF Service, stepwcf

Source: Internet
Author: User

Step by Step to create a WCF Service, stepwcf

 

Address: http://www.cnblogs.com/jfzhu/p/4025448.html

Reprinted please indicate the source

 

(1) create a WCF Service

(1) create a WCF Service Class Library

 

Create a project of Class Library:

Namespace HelloService {// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IHelloService" in both code and config file together. [ServiceContract] public interface IHelloService {[OperationContract] string GetMessage (string name );}}

 

HelloService. cs:

 

namespace HelloService{    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "HelloService" in both code and config file together.    public class HelloService : IHelloService    {        public string GetMessage(string name)        {            return "Hello " + name;        }    }}

 

(2) create a Host for WCF

Add a new ASP. NET Empty Web Application:

<% @ ServiceHost Language = "C #" Debug = "true" Service = "HelloService. HelloService" %>

Web. config:

 

<?xml version="1.0" encoding="utf-8" ?><configuration>  <system.serviceModel>    <services>      <service name="HelloService.HelloService" behaviorConfiguration="metaBehavior">        <endpoint address="HelloService" binding="basicHttpBinding" contract="HelloService.IHelloService"></endpoint>        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>        

 

Specifically, service name = "namespace. Class name" and behaviorConfiguration are used to associate the definition of behavior below.

The endpoint address defines the relative address, which is the complete address combined with baseAddress.

Endpoint contract = "namespace. Interface Name"

Two endpoints. the first binding is basicHttpBinding for HTTP. The second endpoint is used to exchange metadata, and the binding is mexHttpBinding.

Behavior is defined to allow the exchange of metadata.

 

Build solution. If there are no errors, proceed to the next step and deploy the WCF Service to IIS

 

(2) deploying a WCF Service to IIS

(1) Publish HelloServiceIISHost Project

Private void button#click (object sender, EventArgs e) {HelloService. HelloServiceClient client = new HelloService. HelloServiceClient (); label1.Text = client. GetMessage (textBox1.Text );}

 

Run the Code as follows:

<% @ ServiceHost Language = "C #" Debug = "true" Service = "HelloService. HelloService" %>

 

Service code can be found in

(1) file XXX. svc. cs

(2) An independent Assembly (as in this article)

(3) Under the App_Code folder


Who sang a song step by step?

Yesstep by step

It's not a new guy.
But it's a Japanese single.

Step by step 3000: how to use a PART in a day to practice listening? What should I pay attention to during the learning process? Thank you very much.

This set of books is very good, and it is also very suitable for grass-roots people to train and improve their English, not only in terms of listening, but also in terms of Oral English, because they all adopt pure foreign English, it is equal to video truncation.

Usage:
You do not need to hear all the sentences. If you do this, your progress will not only become very slow, but you will not experience the pleasure of rapid progress. There are KEY words in the books, so that you can hear these words and have instantaneous responses. For example, when you mention "HOLE", you can immediately think of "holes", then you will pass.

This is the most basic thing, and you can't do it anymore.
 

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.