使用webservice相同的应用程序多个环境 [英] Consume webservice same application multiple environment

查看:77
本文介绍了使用webservice相同的应用程序多个环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有asp.net应用程序。

我需要从配置文件中使用网络服务网址。



但我有三个环境,下面有3个不同的网址



http:// test / webservice

http:// qa / webservice

http:// prod / webservice



如何在具有相同服务名称的不同配置文件中调用它可能是。



我尝试了什么:



想与uri地址一起工作需要改变动态或直接名称配置文件

I have asp.net application.
I need to consume a web-service url from config files.

But I have three environments with 3 different urls like below

http://test/webservice
http://qa/webservice
http://prod/webservice

how to call this in different config files with same service name might be.

What I have tried:

thinking to work with uri address need to change dynamica or direct name in config files

推荐答案

我的想法是,您可以创建一个来管理3个Web服务。然后使用添加/服务参考添加您的Web服务,然后在新的中添加您可以创建所有函数管理3网络服务。



在你的项目中只需要创建一个对象并调用所有网络服务中的函数



My idea is, you can create a class for manage the 3 webservice. Then you add your webservice with Add/Service Reference and then in the new class you can create all the functions for management the 3 webservice.

In your project only need create one object and call the functions in all the webservices.

public class WebService 
{
   #region webservice1
   //functions
   #endregion
   #region webservice2
   //functions
   #endregion
   #region webservice3
   //functions
   #endregion
}

public void GetNames()
{
   WebService ws = new WebService();
   string[] names1 = ws.webservice1_GetNames();
   string[] names2 = ws.webservice2_GetNames();
   string[] names3 = ws.webservice3_GetNames();
}



我希望我能帮到你。

快乐编码


I hope I can help you.
Happy codding


这篇关于使用webservice相同的应用程序多个环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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