C#动态设置webServer路径

using BD.SD_BJXYZY_PRO.WsbxService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
namespace BD.SD_BJXYZY_PRO.BJXYZY
{
/// <summary>
/// 使用此类时第一步必须先调用DynamicLoadingUrl()方法
/// </summary>
public class myWebservice : WSBX
{
/// <summary>
/// 根据/config/config.Xml文件动态设置webServer路径
/// Author:lijia
/// DateTime:2018-06-05
/// </summary>
public static myWebservice DynamicLoadingUrl()
{
string basePath = AppDomain.CurrentDomain.BaseDirectory;
string WebServerUrl = HttpUtil.GetXmlAttributeValue(basePath + "/config/config.Xml", "WebServerUrl", "value");
myWebservice service = new myWebservice();
service.Url = WebServerUrl;
return service;
}
}
}

使用:

var ws= myWebservice.DynamicLoadingUrl();
string pKey=ws.Open(Ztxx, Dwid, pZgid);

原文地址:https://www.cnblogs.com/hn_lijia/p/9140913.html