There are some ways to hosting WCF service as below:
创新互联是一家专业的成都网站建设公司,我们专注网站设计、成都网站建设、网络营销、企业网站建设,买链接,广告投放为企业客户提供一站式建站解决方案,能带给客户新的互联网理念。从网站结构的规划UI设计到用户体验提高,创新互联力求做到尽善尽美。1. IIS; 2. Console App; 3. Window Service
Using Console Application to host WCF service:
Step 1:
Step 2: Add a Class Library project : 'Contract'
Step 3: Add a Interface : 'IHelloWorld'
using System.ServiceModel;
namespace Contract
{
[ServiceContract(Name= "HelloWorldService")]
public interface IHelloWorld
{
[OperationContract]
string SayHello();
}
}
Step 4: Add a Class : 'HelloWorld'
namespace Contract
{
public class HelloWorld : IHelloWorld
{
public string SayHello()
{
return "Hello World. I'm WCF Service.";
}
}
}
Step 5: Add a Console Application : 'Host'
Step 6:
Use WCF Service Configuration Editor to generate the server config.
Step 7:
Set up server host
using System;
using System.ServiceModel;
using Contract;
namespace Host
{
class Program
{
static void Main(string[] args)
{
using (var host = new ServiceHost(typeof(HelloWorld)))
{
host.Opened+= delegate
{
Console.WriteLine("CalculaorService已经启动,按任意键终止服务!");
};
host.Open();
Console.Read();
}
}
}
}
售后响应及时
7×24小时客服热线数据备份
更安全、更高效、更稳定价格公道精准
项目经理精准报价不弄虚作假合作无风险
重合同讲信誉,无效全额退款