Dynamics CRM 2011编程系列(48): WCF Service 和 Web Service 程序的部署

来源:互联网 发布:mac装机必备 编辑:程序博客网 时间:2024/06/06 08:30

    很多时候我们需要自己发布自己的API给外部程序进行调用,这时候就需要用到WCF或Web Service了。我们来看个简单的例子吧:

Web Service

using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Services;/// <summary>/// Summary description for WebService/// </summary>[WebService(Namespace = "http://tempuri.org/")][WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. // [System.Web.Script.Services.ScriptService]public class WebService : System.Web.Services.WebService {    public WebService () {        //Uncomment the following line if using designed components         //InitializeComponent();     }    [WebMethod]    public string HelloWorld() {        return "Hello World";    }    }

 

WCF Service

using System;using System.Collections.Generic;using System.Linq;using System.Runtime.Serialization;using System.ServiceModel;using System.ServiceModel.Activation;using System.Text;// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service" in code, svc and config file together.[AspNetCompatibilityRequirements(RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed)]public class Service : IService{public void DoWork(){}}


 

部署步骤

 

图1

 

图2

 

图3

 

图4

 

图5

 

图6

 

图7

小结

1.WCF Service 必须放在XrmServices文件夹下,放在其他的位置会出错。具体原因不明

2.WCF Service 和 Web Service 并不一定需要部署在Dynamics CRM 系统的安装目录下,毕竟它们是用来解决异构系统的产品。