C# WSDL.exe生成的Web服务代理代码与;更新网页参考资料";-我应该在乎吗?
使用VisualStudio2010,我们有一个包含多个网站(不是web应用程序项目)以及命令行和winforms项目的解决方案。所有目标都是.NET2.0。许多项目在网站中有对ASMX web服务的web引用 web服务经常更改,因此当我们编译所有内容时,我们必须手动检查所有项目并更新web服务引用。我现在已经成功地使用和自动化了这个。但是我担心wsdl.exe生成的代码与VS wsdl.exe生成如下代码:C# WSDL.exe生成的Web服务代理代码与;更新网页参考资料";-我应该在乎吗?,c#,web-services,wsdl,asmx,disco,C#,Web Services,Wsdl,Asmx,Disco,使用VisualStudio2010,我们有一个包含多个网站(不是web应用程序项目)以及命令行和winforms项目的解决方案。所有目标都是.NET2.0。许多项目在网站中有对ASMX web服务的web引用 web服务经常更改,因此当我们编译所有内容时,我们必须手动检查所有项目并更新web服务引用。我现在已经成功地使用和自动化了这个。但是我担心wsdl.exe生成的代码与VS wsdl.exe生成如下代码: public WebServiceName() { string urlSe
public WebServiceName() {
string urlSetting = System.Configuration.ConfigurationManager.AppSettings["WebServiceName"];
if ((urlSetting != null)) {
this.Url = urlSetting;
}
else {
this.Url = "http://example/webservicename.asmx";
}
}
private bool useDefaultCredentialsSetExplicitly;
public WebServiceName() {
this.Url = global::ProjectName.Properties.Settings.Default.ProjectName_WebServiceNameWebService_WebServiceName;
if ((this.IsLocalFileSystemWebService(this.Url) == true)) {
this.UseDefaultCredentials = true;
this.useDefaultCredentialsSetExplicitly = false;
}
else {
this.useDefaultCredentialsSetExplicitly = true;
}
}
public new string Url {
get {
return base.Url;
}
set {
if ((((this.IsLocalFileSystemWebService(base.Url) == true)
&& (this.useDefaultCredentialsSetExplicitly == false))
&& (this.IsLocalFileSystemWebService(value) == false))) {
base.UseDefaultCredentials = false;
}
base.Url = value;
}
}
public new bool UseDefaultCredentials {
get {
return base.UseDefaultCredentials;
}
set {
base.UseDefaultCredentials = value;
this.useDefaultCredentialsSetExplicitly = true;
}
}
private bool IsLocalFileSystemWebService(string url) {
if (((url == null)
|| (url == string.Empty))) {
return false;
}
System.Uri wsUri = new System.Uri(url);
if (((wsUri.Port >= 1024)
&& (string.Compare(wsUri.Host, "localHost", System.StringComparison.OrdinalIgnoreCase) == 0))) {
return true;
}
return false;
}
VS生成如下代码:
public WebServiceName() {
string urlSetting = System.Configuration.ConfigurationManager.AppSettings["WebServiceName"];
if ((urlSetting != null)) {
this.Url = urlSetting;
}
else {
this.Url = "http://example/webservicename.asmx";
}
}
private bool useDefaultCredentialsSetExplicitly;
public WebServiceName() {
this.Url = global::ProjectName.Properties.Settings.Default.ProjectName_WebServiceNameWebService_WebServiceName;
if ((this.IsLocalFileSystemWebService(this.Url) == true)) {
this.UseDefaultCredentials = true;
this.useDefaultCredentialsSetExplicitly = false;
}
else {
this.useDefaultCredentialsSetExplicitly = true;
}
}
public new string Url {
get {
return base.Url;
}
set {
if ((((this.IsLocalFileSystemWebService(base.Url) == true)
&& (this.useDefaultCredentialsSetExplicitly == false))
&& (this.IsLocalFileSystemWebService(value) == false))) {
base.UseDefaultCredentials = false;
}
base.Url = value;
}
}
public new bool UseDefaultCredentials {
get {
return base.UseDefaultCredentials;
}
set {
base.UseDefaultCredentials = value;
this.useDefaultCredentialsSetExplicitly = true;
}
}
private bool IsLocalFileSystemWebService(string url) {
if (((url == null)
|| (url == string.Empty))) {
return false;
}
System.Uri wsUri = new System.Uri(url);
if (((wsUri.Port >= 1024)
&& (string.Compare(wsUri.Host, "localHost", System.StringComparison.OrdinalIgnoreCase) == 0))) {
return true;
}
return false;
}
其他一切基本上都是一样的。我需要为此担心吗?这当然意味着我们必须改变覆盖URL在app.config和web.config文件中的存储方式。wsdl.exe使用appSettings,VS使用configSections/applicationSettings
我知道ASMX是旧的,WCF是新的。我受够了
更新:
找到了这篇讨论差异的文章:
如何跨多个Web应用程序项目共享动态URL
既然没有人回应(是的,风滚草!),我至少会发布我的发现。如果您确实想查看VS代码是如何生成的,可以在Microsoft.VSDesigner.dll中找到它。我的机器有8.0和9.0版本。这是路。我不知道这是否与您系统上的匹配:
C:\Windows\assembly\GAC_MSIL\Microsoft.VSDesigner\8.0.0.0__b03f5f7f11d50a3a\Microsoft.VSDesigner.dll
如果使用打开,请查看
Microsoft.VSDesigner.CodeGenerator.DiscoCodeGenerator
中的GenerateCode
方法。这将调用该方法来生成基本代码,就像Wsdl.exe那样,然后它修改代码以获得VS结果。Wow!有1000人看过这个问题(拿到了徽章!),但没有人评论或回答。我很想听听你对此的想法。我想这么做是不是疯了?你找到别的方法了吗?等