我可以更改配置文件中的 Web 服务引用 URL 吗?

发布于 2024-08-04 05:29:15 字数 206 浏览 5 评论 0原文

我有一个针对 2.0 .NET 框架的应用程序。解决方案是使用 VS Web 服务引用文件夹。通过该解决方案进行 grep 查询可以发现该 URL 存在于少数文件中。然而,在已部署的应用程序中,搜索显示 URL 仅存在于 .config 中。那么 .disco 和 .wsdl 发生了什么?它们被编译成.exe吗?基本上,我需要更新 URL,并且需要知道这是否需要新的构建。

谢谢!

I have an application targeting the 2.0 .NET framework. The solution is using the VS web service reference folder. A grep through the solution reveals that this URL lives in a handful of files. However in the deployed application a search shows that the URL lives in only the .config. So what happened to the .disco and .wsdl? Are they compiled into the .exe? Basically, I need to update the URL and I need to know if this requires a new build.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

柠檬色的秋千 2024-08-11 05:29:15

是的,您可以更改运行时引用的 URL。

如果它位于 .config 文件中,IIS 将 您的应用程序应检测 .config 文件中的更改并加载新值。如果没有,那么您必须重新启动客户端。 也许您可以在 IIS 中停止并启动网站。

此外,您绝对可以编写代码以从 .config 文件中读取。

  var myWS = new MyWebService();
  myWS.Url = WebServiceURL;
  myWS.SomeMethod();                     

private static string WebServiceURL { 
   get { return ConfigurationManager.AppSettings["MyWebServiceURL"].ToString(); }           }

同时在您的 .config 文件中,您有:

  <appSettings>
    <add key="MyWebServiceURL" value="http://blah/foo/bar.asmx" />
  </appSettings>

Yes, you can change the URL that's being referenced at runtime.

If it's in a .config file, IIS will your app should detect the change in the .config file and load the new value. If not, then you'd have to restart the client. Perhaps you can stop and start the Web Site in IIS.

Further, you can definitely WRITE your code to read from a .config file.

  var myWS = new MyWebService();
  myWS.Url = WebServiceURL;
  myWS.SomeMethod();                     

private static string WebServiceURL { 
   get { return ConfigurationManager.AppSettings["MyWebServiceURL"].ToString(); }           }

Meanwhile in your .config file, you have:

  <appSettings>
    <add key="MyWebServiceURL" value="http://blah/foo/bar.asmx" />
  </appSettings>
勿挽旧人 2024-08-11 05:29:15

您可以更改 Web 配置中的 url(如果 Web 服务保持不变。不太确定 Web 服务是否已更改)

You can change the url in the web config (if the webservice remains unaltered. Not so sure if the webService as changed)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文