vs2010 WebService为何找不到Begin、End方法

hugofgh 2012-08-13 09:40:57
WebService中写一个方法应该会在外部调到3个方法,第一个是自己写的,第二个是begin开头的,第三个是end开头的.. 在网上查了一下,http://www.cnblogs.com/smallstone/archive/2010/05/27/1745275.html。
To do that, you need unload the project from VS, and edit the project file directly in an editor. (Please backup one in case you do something wrong.)
In the first section of PropertyGroup, you will see many properties like:
<ProjectGuid>{F4DC6946-F07E-4812-818A-F35C5E34E2FA}</ProjectGuid>
<OutputType>Exe</OutputType>
...
Don't change any of those, but do add an extra property just like the OutputType into that section like:
<WebReference_EnableLegacyEventingModel>true</WebReference_EnableLegacyEventingModel>
Ignore the warning from the xml editor, save the file, and reload the project into VS.
After that, you have to regenate all proxy code (by updating the reference, or running the custom tool on the .map file)

问题是我在winform中在哪添加相应的 <WebReference_EnableLegacyEventingModel>true</WebReference_EnableLegacyEventingModel>
谢谢!!
...全文
517 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
studentsky 2013-04-26
  • 打赏
  • 举报
回复
8楼正解,谢谢!
hugofgh 2012-08-13
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]
E文没有看懂吗,大概的意思是关闭对应的Project文件,以防万一先做个备份,然后用notepad这样的编辑器打开Project文件,在第一个PropertyGroup节点中添加Project的属性。把WebReference_EnableLegacyEventingModel节点添加到OutputType节点后面就可以。然后在VS中重新打开Project,选择WebService右键菜单中选择“……
[/Quote]

Service Reference右键菜单中没有“配置服务引用”,只有“添加服务引用”,难道要重新添加?

ps:刚回的贴怎么不见了
hugofgh 2012-08-13
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]

E文没有看懂吗,大概的意思是关闭对应的Project文件,以防万一先做个备份,然后用notepad这样的编辑器打开Project文件,在第一个PropertyGroup节点中添加Project的属性。把WebReference_EnableLegacyEventingModel节点添加到OutputType节点后面就可以。然后在VS中重新打开Project,选择WebService右键菜单中选择……
[/Quote]


我看到“添加服务引用”的高级选项中有“生成异步操作”,但是对于已有的我没有发现“配置服务引用”
hugofgh 2012-08-13
  • 打赏
  • 举报
回复
针对已添加的Service Reference右键菜单“配置服务引用”后选中“生成异步操作”确定后就有Begin/End方法了。

但是 我右键Service Reference 只有“添加服务引用”,没有“配置服务引用” ,难不成要重新添加?
datafansbj 2012-08-13
  • 打赏
  • 举报
回复
在引用WebService的时候,记得可以修改一个参数什么的,好像是确定生成的引用代码是否支持异步调用,可能你生成的引用,没有选择异步调用选项。
Jia_H 2012-08-13
  • 打赏
  • 举报
回复
E文没有看懂吗,大概的意思是关闭对应的Project文件,以防万一先做个备份,然后用notepad这样的编辑器打开Project文件,在第一个PropertyGroup节点中添加Project的属性。把WebReference_EnableLegacyEventingModel节点添加到OutputType节点后面就可以。然后在VS中重新打开Project,选择WebService右键菜单中选择“更新Web引用”,更新完后就有Begin/End方法了。

对于Service Reference(服务引用)如WCF的,可以通过添加Reference时选择下面的“高级(V)...”后选中“生成异步操作”或者针对已添加的Service Reference右键菜单“配置服务引用”后选中“生成异步操作”确定后就有Begin/End方法了。
hugofgh 2012-08-13
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 的回复:]
我是用天气预报Web Service作试验的。你也可以参考试一试:
Service URL: http://www.webxml.com.cn/WebServices/WeatherWebService.asmx

1. 做为旧的Web Service使用(Web Reference)
生成的WeatherWebService没有Begin/End方法
关闭project后用no……
[/Quote]

好的 谢谢 我试试
Jia_H 2012-08-13
  • 打赏
  • 举报
回复
我是用天气预报Web Service作试验的。你也可以参考试一试:
Service URL: http://www.webxml.com.cn/WebServices/WeatherWebService.asmx

1. 做为旧的Web Service使用(Web Reference)
生成的WeatherWebService没有Begin/End方法
关闭project后用notepad编辑对应csproj文件。更改完成后重新打开project,选中Web References下面对应的Web Refrence右键菜单中选择“更新Web引用”,更新完后就有Begin/End方法了。

参考下面更改后的内容(需要在第一个PropertyGroup节点中添加)。

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build"

xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{DECB98A2-0FC4-46B5-9857-D828F4332E8F}</ProjectGuid>
<OutputType>WinExe</OutputType>
<WebReference_EnableLegacyEventingModel>true</WebReference_EnableLegacyEventingModel>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Test</RootNamespace>
<AssemblyName>Test</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<!-- 省略掉其他内容 -->
</Project>

2. 做为新的Service Reference使用
a. 不选中“生成异步操作”(缺省状态)
生成的WeatherWebServiceSoapClient只有5个get***方法。
b. 选中“生成异步操作”
生成的WeatherWebServiceSoapClient中包含Being/End***, get***以及***Async等内容了。
hugofgh 2012-08-13
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 的回复:]
旧的Web Service就用手动编辑project文件的方式,新的就用上面介绍的方法。没有你就添加,试试有不会损失什么。
[/Quote]


试了,用记事本编辑了project,加上了 <WebReference_EnableLegacyEventingModel>true</WebReference_EnableLegacyEventingModel>
重新打开,生成后还是没有end 和start方法
Jia_H 2012-08-13
  • 打赏
  • 举报
回复
旧的Web Service就用手动编辑project文件的方式,新的就用上面介绍的方法。没有你就添加,试试有不会损失什么。

110,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧