Web服务命名空间动态命名 [英] Web Service Namespace Dynamic Naming

查看:64
本文介绍了Web服务命名空间动态命名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 web服务,我将将其部署到开发,登台和生产中.随之而来的是一个 ASP.net 应用程序,该应用程序将单独部署,但也将在这三个阶段中进行部署.

I have a web-service that I will be deploying to dev, staging and production. Along with this will be an ASP.net application that will be deploying separately but also in those three stages.

更改Web服务中的以下行以匹配当前环境的最实用方法是什么?

What is the most pragmatic way to change the following line in the web-service to match the current environment?

[WebService(Namespace = "http://dev.mycompany.com/MyAppsWebService")]
[WebService(Namespace = "http://stage.mycompany.com/MyAppsWebService")]
[WebService(Namespace = "http://mycompany.com/MyAppsWebService")]

推荐答案

您的Web服务对象具有"URL"属性,可以通过web.config文件进行设置.将Web引用添加到应用程序时,会创建一个配置文件,您应该将其内容复制到web.config或app.config文件中.然后,您可以部署配置文件,而不必管理任何代码更改即可适应url中的更改.

Your webservice object has a "URL" property on it which can be set via the web.config file. There's a config file that gets created when you add the web reference to your application that you should copy the contents of to your web.config or app.config file. You can then deploy the config file and not have to manage any code changes to accomodate the change in url.

这篇关于Web服务命名空间动态命名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆