ChengDa_English/SGGL/FineUIPro.Web/common/ServiceProxy.cs

39 lines
1.5 KiB
C#
Raw Normal View History

2022-12-20 09:32:32 +08:00
namespace FineUIPro.Web
{
using System;
using System.Configuration;
using System.ServiceModel;
using System.Collections.Generic;
using System.Linq;
using BLL;
using System.Xml;
public static class ServiceProxy
{
2023-07-13 10:09:46 +08:00
///// <summary>
///// 创建客户端服务
///// </summary>
public static BLL.CNCECHSSEService.HSSEServiceClient CreateServiceClient()
{
string address = ConfigurationManager.AppSettings["endpoint"];
var proxy = new BLL.CNCECHSSEService.HSSEServiceClient();
ConfigEndpointAddress<BLL.CNCECHSSEService.HSSEService>(proxy, address);
return proxy;
}
2022-12-20 09:32:32 +08:00
2023-07-13 10:09:46 +08:00
/// <summary>
/// 根据web.config中服务器端主机地址配置服务通道的终端地址。
/// </summary>
/// <typeparam name="TChannel">通道类型</typeparam>
/// <param name="proxy">代理</param>
/// <param name="endpointAddress">服务访问地址</param>
public static void ConfigEndpointAddress<TChannel>(System.ServiceModel.ClientBase<TChannel> proxy, string endpointAddress)
2022-12-20 09:32:32 +08:00
where TChannel : class
{
Uri endpointUri = new Uri(endpointAddress);
EndpointAddress endPointAddress = new EndpointAddress(endpointUri);
proxy.Endpoint.Address = endPointAddress;
}
}
}