diff --git a/Falcon.SugarApi.WebService/Readme.md b/Falcon.SugarApi.WebService/Readme.md index 000c24d..ded57d0 100644 --- a/Falcon.SugarApi.WebService/Readme.md +++ b/Falcon.SugarApi.WebService/Readme.md @@ -2,13 +2,14 @@ ### 服务端 -1. 首先使用IServiceCollection.AddWebServices注册服务及其实现。 -2. 使用IApplicationBuilder.UseRouting()应用路由中间价。 +1. 首先定义协议及其实现。 +2. 使用IServiceCollection.AddWebServices注册服务及其实现。 +2. 使用IApplicationBuilder.UseRouting()应用路由中间件。 3. 调用IApplicationBuilder.UseWebServiceEndpoint方法应用中间件。 ### 客户端 -1. 调用WebServiceClient.CreateWebServiceClient方法创建客户端。T为服务端应以的协议接口,返回T协议对应的通信实现。 +1. 调用WebServiceClient.CreateWebServiceClient泛型方法创建客户端。泛型为服务端应以的协议,方法返回协议对应的通信实现。 ### 实例 @@ -25,6 +26,9 @@ public string HellowWorld(string name); } + /// + /// Web服务协议实现 + /// public class WebSvc:IWebSvc { public string HellowWorld(string name) { @@ -32,6 +36,8 @@ } } + //Program.cs + using Falcon.SugarApi.WebService; using Server; @@ -50,16 +56,24 @@ ~~~c# using System.ServiceModel; - [ServiceContractAttribute(ConfigurationName = "Service.IWebSvc")] + + + /// + /// Web服务协议,与服务端匹配 + /// + [ServiceContract] internal interface IWebSvc { - [OperationContractAttribute(Action = "http://tempuri.org/IWebSvc/HellowWorld",ReplyAction = "http://tempuri.org/IWebSvc/HellowWorldResponse")] + [OperationContract] Task HellowWorldAsync(string name); } + + //Program.cs using Falcon.SugarApi.WebService; - var svc = WebServiceClient.CreateWebServiceClient("http://localhost:5000/WebService.asmx"); + var url="http://localhost:5000/WebService.asmx"; + var svc = WebServiceClient.CreateWebServiceClient(url); var result=await svc.HellowWorldAsync("Jeck"); ~~~ \ No newline at end of file