浏览 1037 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2015-11-16
新建C#工程 在VS中,新建一个名为HelloSoap的控制台应用程序的工程: ![]() 添加引用 将RuleEngine.dll添加到引用中。该文件一般位于VisualRulesSolution安装目录的samples\notnet\RuleEngine\bin\Release目录下: ![]() 添加服务引用 ![]() 然后输入Soap服务所在的地址,在地址栏中输入http://192.168.19.128:8880/soap/services/RuleSoap?wsdl 。 点击“前往”后,可以看到规则服务提供的接口。 输入一个命名空间后,点击确认。 ![]() 图3-1-2-5-4 添加服务引用 编写Program.cs 在此中输入三个类,RuleSoapFactory、RuleSoapService、Program,其中RuleSoapFactory、RuleSoapService是对规则调用接口的实现。其他程序都可以像Program操作的那样,调用规则包。: using System; using System.Collections.Generic; using System.Linq; using System.Text; using RuleEngine; namespace HelloSoap { public class RuleSoapFactory : RuleServiceFactory { override public RuleService RuleService { get { return new RuleSoapService(this); } } public RuleSoapFactory() : base() { } public virtual void close() { } public virtual void forceClose() { this.close(); } public virtual void open() { } } public class RuleSoapService : AbstractRuleService { private RuleSoapFactory Factory { get { return (RuleSoapFactory)factory; } } public RuleSoapService(RuleSoapFactory factory) : base(factory) { } protected override System.String send(System.String xml) { try { HelloSoap.ServiceReference1.RuleSoapClient soap = new HelloSoap.ServiceReference1.RuleSoapClient(); return soap.getRule(xml); } catch (System.Exception e) { Factory.forceClose(); throw new RuleServiceException(e); } } } class Program { static void Main(string[] args) { RuleSoapFactory factory = new RuleSoapFactory(); RuleService service = factory.RuleService; service.put("name", "测试Soap访问"); service.execute("hello"); Console.WriteLine(service.getString("welcome")); Console.Read(); } } } 执行测试类 点击执行后,看到执行结果如下,说明已经调用规则包成功: ![]() 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |