Linux学习日记-WCF RestFul的部署(三)

一、关于WCF 的部署

默认的wshttp风格的wcf是很容易部署上去的,但是这里给个建议尽量不要使用WCF的配置文件去部署尽管

我们都已经很熟悉了,在使用配置文件你会发现各种蛋疼的问题。

二、WCF Restful的部署

以下是简单的目录:

   aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAASYAAAD4CAIAAADO5dxmAAAftElEQVR4nO3dW1Rb150/8PM09cN//mlWMvl3TWY1nodpslbrrJkF/5esaabT1PakbkniZvwAJXGaxJ1Om8Sx47j2YAMC3wKUO+YugUDhjiGAhLnKYAx2MNiYq0BGBYEgWNsI3QB7aR6OdHR0QyIR+0DyPeuzumSx9znm1N/sfc7R/onRzOo2JAtnIiXc6xCRkn0tjQyJ6dU4XjMRMvvrblGIo40kggmX8nfVGx3i9o7r/qWRzIabR18AeopLZMUlsiJpqaS4pEhayv7RrY2kuERWVllWUT2nWyqrqJaVVUqKS9zaMH6O1C0K4eI0KwsPEUVHuOYgQuaMljSSceZTx2aMS6YkgnEmkyONZLgYc0dhGIaJjI4JDYkRhTPeegFQV/p5+efllXyln5e7tZnTLZV+Xj6nW3J7zecncpKI0OhunWZWp4wJZRiG8TrKzToaeMmGfWRTxoS6tmdzxTCMff/OQzhC6+ziGP3cjghA05xuyZPXZl5fc/yNcgAQVIgcAFWIHABViBwAVYgcAFWIHABViBwAVYgcAFWIHABViBwAVYFG7lp3j7SkNEDXunsE/8UAtqdAI1csLSGEEEIMBsPa2prNY1tfXzeZTMvLy4SQYqn7p6cBgBVo5IqKpYQQrVY7Pz+/uLi45LG1tbUtLi42NzcTQoqKpYL/YgDbU6CRkxQVs5Gbm5vT6XRf8TYudQsLC3Nzc4QQSVGxS1+XhXOycN7qAZe1drO90SGONUH2JQvcggOsJIBviUAjJ5YUEULm4nUzsVpN9AzfTKx2Ll7HIYSIJUUu3d3WsPLC41yh0y0K4S9C7RZFS3Xu+QTY+ZjW9mu7du1yW3+9a9eu1vZr/HYFhWJCiDZufvrsX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cAFWIHABViBwAVYgcAFWIHABViBwAVYgcAFWIHABViBwAVYgcAFWIHABViBwAVYgcAFWIHABViBwAVYgcAFWIHABViBwAVYgcAFWIHABViBwAVYgcAFWIHABViBwAVYgcAFWIHABViBwAVYgcAFWIHABV/wtj9eX2kgLSpwAAAABJRU5ErkJggg==" alt="" />

最主要的是主机的代码:

      注: 一定要用代码,而不用配置文件 否则帮助页、默认返回格式什么的以配置就报异常

接口IService 类
using System;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web; namespace Services
{
[ServiceContract]
public interface IService
{
[OperationContract,WebGet(UriTemplate="test/{name}")]
string GetData (string name);
}
} 服务Service 类
using System; namespace Services
{
public class Service:IService
{
public string GetData(string name)
{
return name; }
}
} 主机启动服务的方法: using System;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.ServiceModel.Description;
using Services; namespace Hosting
{
class MainClass
{
public static void Main (string[] args)
{
using (WebServiceHost host = new WebServiceHost (typeof(Services.Service))) {
//host.AddServiceEndpoint(typeof(ICalculator), new WebHttpBinding(), "http://127.0.0.1:9999/"); ServiceEndpoint endpoint = host.AddServiceEndpoint(typeof(Services.IService), new WebHttpBinding(), "http://127.0.0.1:9999/");
if (host.Description.Behaviors.Find<WebHttpBehavior> () == null) {
WebHttpBehavior httpBehavior = new WebHttpBehavior ();
httpBehavior.HelpEnabled = true; //打开帮助页
httpBehavior.DefaultOutgoingResponseFormat = WebMessageFormat.Json;//指定返回格式为“Json”
httpBehavior.DefaultBodyStyle = WebMessageBodyStyle.Bare; //正文消息样式
httpBehavior.AutomaticFormatSelectionEnabled = false; //是否自动返回格式
endpoint.Behaviors.Add (httpBehavior);//添加终结点
}
host.Opened += delegate {
Console.WriteLine ("服务已启动!");
};
host.Open();
Console.ReadKey();
}
}
}
}

using System;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;

namespace Services
{
    [ServiceContract]
    public interface IService
    {
        [OperationContract,WebGet(UriTemplate="test/{name}")]
        string GetData (string name);
    }
}

上一篇:subprocess模块在Windows下调用失败问题


下一篇:spring in action学习笔记十五:配置DispatcherServlet和ContextLoaderListener的几种方式。