我在使用Web引用的Visual Studio中创建应用程序。为参考的网址是:为每个用户提供不同URL的Web服务引用
https://nameSurname.website.com/defectsservice.asmx
这是我如何使用它在我的代码:
DefectsService.Defect defect = new DefectsService.Defect();
defect.Name = mo.DefectName;
defect.DateFound = DateTime.Now;
noDefect = new DefectsService.DefectHandler().AddDefect(mo.Guid, defect);
//DefectsService is the name of the service which I give when I add the reference
我需要这样的应用程序:用户将进入他的网址和他服务将被使用。正如我所看到的,唯一将URL写入解决方案的地方是在app.config文件中。但是,如果我去'显示所有文件',那么会出现更多带有URL的文件,例如config.svcinfo,References.cs等等。所以,我有一个问题:
在我的解决方案中,我添加了服务我的名字和姓氏在URL中。如果我像这样(添加服务)离开它,并且当用户输入他的URL时,我只更改app.config文件,上面的代码是否会像他的服务一样工作,而不是我的服务?或者不是,因为当我添加它时服务已经有了我的URL?
UPDATE
这里是Wiktor的Zychla的建议后,我的代码:
class Program : System.Web.Services.Protocols.SoapHttpClientProtocol
{
public Program()
{
this.Url = "";//url entered from every user
}
static void Main(string[] args)
{
DefectsService.Defect d = new DefectsService.Defect();
defect.Name = mo.DefectName;
defect.DateFound = DateTime.Now;
noDefect = new DefectsService.DefectHandler().AddDefect(mo.Guid, defect);
//DefectsService is the name of the service which I give when I add the reference
}
}
defectsservice.websi te.com/nameSurname将是一个很容易做... –
@TonyHopkinson该服务不是我的,所以我不能改变它。 –
啊,对不起,棒的结束。这应该有所帮助。 http://stackoverflow.com/questions/473028/how-to-edit-application-configuration-settings-app-config-best-way-to-go –