222
schangxiang@126.com
2024-12-12 9f61c92fe6864d536a0e3a6e041cbd788dcec752
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using CCWcfService;
using System.ServiceModel;
 
namespace Admin.NET.Application.CommonHelper
{
    /// <summary>
    /// WCF服务帮助类
    /// </summary>
    public class WCFServiceHelper
    {
 
        /// <summary>
        /// 获取SAPCC的WCF服务 Client对象
        /// </summary>
        /// <returns></returns>
        public static async Task<ICCWcfService> GetWCFService_SAPCC_Client(SqlSugarRepository<SysConfig> _sysConfigRep)
        {
            var config = await _sysConfigRep.GetFirstAsync(x => x.Code == "CCWcfAddress");
            if (config == null)
            {
                throw Oops.Oh("没有找到配置编号'CCWcfAddress'的数据");
            }
            var endpoint = config.Value;
            var factory = new ChannelFactory<ICCWcfService>(new BasicHttpBinding(), new EndpointAddress(endpoint));
            var client = factory.CreateChannel();
            return client;
        }
 
    }
}