IIS as a WCF host, example

Source: Internet
Author: User

1. Create a new WCF service, you can create a new class and write it according to the standards of the WCF service.

Interface:

Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Runtime.Serialization;
Using System.ServiceModel;
Using System.Text;

Namespace MyService
{
[ServiceContract]
public interface Imyservice
{

[OperationContract]
void DoWork ();

void Closecomputer (string IP);
[OperationContract]
String Registmypcinfo (string mypcinfo);
}
}

Realize:

Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Web;

Namespace MyService
{
public class Service:imyservice
{

public void DoWork ()
{
throw new NotImplementedException ();
}

public void Closecomputer (String mac)
{

}
public string Registmypcinfo (string mypcinfo)
{
Return "IP is:" + Mypcinfo + "registered successfully in the database";
}

}
}

2. Just write WCF, no configuration file is written. The host is written below. Create a new empty Web program myhosting, create a new Myservice.svc file in the project, add <%@ ServiceHost language= "C #" debug= "true" service= "with Notepad edit Myservice.service "%> then save. Add a reference-"project-" to the service class project that was just written in the empty Web program. To compile.

3. Build the Myhosting project and place it under the IIS server to start.

IIS as a WCF host, example

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.