简体   繁体   English

.net Web服务参考发布时更新

[英].net web service reference update while publishing

I have a web site project in which I use a web service to get data. 我有一个网站项目,在其中使用Web服务获取数据。 The service is an .asmx within the same project as the website. 该服务是与网站位于同一项目中的.asmx。 Therefor the reference for this web service (endpoint in web.config, .svcinfo, .disco, .wsdl, and .svcmap) points to localhost while development. 因此,此Web服务的参考(web.config,.svcinfo,.disco,.wsdl和.svcmap中的端点)在开发时指向localhost。 When deploying the web site (publish) I need the references to be updated before building so that it points to where I'm deploying it. 部署网站(发布)时,我需要在构建之前更新参考,以使其指向我要部署的位置。

I have used web.config-transformations in different build contexts to update the references in web.config and tried to create a BeforeBuild task to generate .wsdl, .svcinfo, etc by calling SvcUtil.exe. 我在不同的构建上下文中使用了web.config-transformation来更新web.config中的引用,并尝试通过调用SvcUtil.exe创建一个BeforeBuild任务来生成.wsdl,.svcinfo等。

Web.config transformations work fine but SvcUtil.exe tries to discover the web service on the deployed address to generate the files so... as all this occurs while deploying then no files are generated due to there is no web service in the target address yet. Web.config转换工作正常,但SvcUtil.exe尝试在已部署地址上发现Web服务以生成文件,因此...由于所有这些都在部署时发生,因此由于目标地址中没有Web服务而未生成文件然而。

I figured out that the flow should be something like: 我发现流程应该是这样的:
1- get target address from web.config-transformations 1-从web.config-transformations获取目标地址
2- discover the LOCAL (within the project, not in the target) web service 2-发现本地(在项目中,而不在目标中)Web服务
3- create or update .wsdl, .disco, etc with target address 3-使用目标地址创建或更新.wsdl,.disco等
4- build 4-构建
5- deploy 5-部署

But I'm out of ideas on how to make it work... any ideas? 但是我对如何使它起作用没有任何想法...有什么想法吗?

I am not sure if this applies to ASMX but in WCF it is enough to modify web.config using config transformations. 我不确定这是否适用于ASMX但在WCF是否足以使用config转换来修改web.config。 No need to update service reference again. 无需再次更新服务参考。 Update service reference only when there are changes in service methods. 仅当服务方法发生变化时才更新服务参考。

Generated service classes should use relative addresses. 生成的服务类应使用相对地址。 Address prefix is then red from web.config file. 然后,web.config文件中的地址前缀为红色。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM