惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 【当耐特】
Help Net Security
Help Net Security
P
Proofpoint News Feed
J
Java Code Geeks
爱范儿
爱范儿
Last Week in AI
Last Week in AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
F
Full Disclosure
Google DeepMind News
Google DeepMind News
H
Help Net Security
G
Google Developers Blog
Jina AI
Jina AI
Vercel News
Vercel News
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
L
Lohrmann on Cybersecurity
S
Schneier on Security
Microsoft Azure Blog
Microsoft Azure Blog
IT之家
IT之家
Security Archives - TechRepublic
Security Archives - TechRepublic
阮一峰的网络日志
阮一峰的网络日志
N
News and Events Feed by Topic
GbyAI
GbyAI
B
Blog
O
OpenAI News
博客园_首页
Cisco Talos Blog
Cisco Talos Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Hacker News: Ask HN
Hacker News: Ask HN
TaoSecurity Blog
TaoSecurity Blog
腾讯CDC
MongoDB | Blog
MongoDB | Blog
M
MIT News - Artificial intelligence
C
Cybersecurity and Infrastructure Security Agency CISA
Cyberwarzone
Cyberwarzone
Webroot Blog
Webroot Blog
Simon Willison's Weblog
Simon Willison's Weblog
Y
Y Combinator Blog
C
Cisco Blogs
A
Arctic Wolf
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
The Exploit Database - CXSecurity.com
Security Latest
Security Latest
AI
AI
W
WeLiveSecurity
aimingoo的专栏
aimingoo的专栏
The Register - Security
The Register - Security
Project Zero
Project Zero
H
Hackread – Cybersecurity News, Data Breaches, AI and More
N
Netflix TechBlog - Medium
Blog — PlanetScale
Blog — PlanetScale

博客园 - 流泉飞石

转:ADO.Net Entity Framework : (七) 多條件查詢 转载:GridView 空记录时显示 Header 代码重构相关书籍 转:恢复Reflector反编译后资源文件的办法 WPF 回车转Tab实现跳转 C#自定义快捷键实现介绍 C#程序多用户只启动一个进程的方法[转载] C#中自定义快捷键【转载】 转:[WPF] WPF资源收集 分享 转:.NET开发人员必知的八个网站 WatermarkComboBox 和 WatermarkTextBox 转:c#中线程访问winform控件的若干问题 [转] DotNet资源站点汇总 DataKeyNames工作 - 流泉飞石 - 博客园 转:功能很强大的UIHelper类 转:CS结构软件自动升级实现 几个很好的url重写工具 asp.net获取应用程序路径 - 流泉飞石 - 博客园 SqlServer 查询sql执行时间
转:动态修改webservice地址
流泉飞石 · 2009-11-11 · via 博客园 - 流泉飞石

方法一:有时候需要动态的设置 WebService 的地址,这样发布到不同的服务器时就要重新生成,为此我们需要在web.config中动态配置WebService的地址,在网上查了很多资料,其中这种方法感觉很好用也很好实现,修改本地的代理类(添加一个新类,继承你的 WebService代理类)

namespace Web_Service
{
   [System.Diagnostics.DebuggerStepThrough(),System.ComponentModel.DesignerCategory("code"),
  System.Web.Services.WebServiceBinding(Name = "", Namespace = "")]
  public class DynWebService : SelfWebService
  {
      public DynWebService() : base()
     {
       //设置默认webService的地址
       this.Url = "http://localhost/WebService.asmx";
     }
     public DynWebService(string webUrl) : base()
     {
         this.Url = webUrl;
     }
  }
}

说明:SelfWebService 你引用的 WebService

Web Service的URI部署到配置文件里

<add key="WebServiceKey" value="http://xxxx/WebService.asmx"/>

最后实现(调用)

private void WebServiceTest()
{
  string webServiceUrl = ConfigurationManager.AppSettings["WebServiceKey "].ToString();
  Web_Service.DynWebService dws = new Web_Service.DynWebService(webServiceUrl);
  string result = dws.HelloWorld();
}

注:HelloWord()为你所调用的Webservice的方法,这里是假设它返回的是String类型的值!

OK 到这里就搞定了!

方法二:

你就選擇你的客戶端的web   serivce   的那個文件夾(就像個地球形狀的那個)我的名字是localhost的文件夾,然後右健選擇屬性   有個url行為然後將靜態修改成動態。web.config裡面會出現 

<add key="Webpos.localhost.MyService" value="http://localhost/SoapService/MyService.asmx"/>

我的是這個樣子的可能因你的web   service   而異。這個時候  
  http://localhost/accessWebpos/Web   References/localhost/Reference.cs  
  文件中會出現

public MyService()   
{   
     string urlSetting =  System.Configuration.ConfigurationSettings.AppSettings["Webpos.localhost.MyService"];   
     if ((urlSetting != null))   
       {   
          this.Url   =   string.Concat(urlSetting, "");   
                          
       }   
                          
      else 
       {   
        this.Url   =   "http://localhost/SoapService/MyService.asmx";   
       }   
 }