共用方式為


Add an old (8.0) style web reference into an Orcas (VS 9) project

In VS 9, the "Add Web Reference" menu command was "replaced" by "Add Service Reference" command in all client projects (VB/C#) targeting 3.x platform. Although "service reference" works for most existing web servers, the proxy generated from "Service Reference" and the old "Web Reference" is very different. The service reference is actually a new WCF client, which gives us a lots of flexibility through its configuration system. However, it is fairly different from the old Web Reference API, and the old code consuming old reference certainly will not work without extra work. And there is a tricky part when we use a WCF client to consume an old web reference: the WCF expects you to define types with new DataContract format, and most type defined in web reference is XmlSerialiable types. The proxy generator might not work well with the default options, and sometime, we have to adjust some options to make it to work. (Often the "Auto" serializer doesn't work, and we might have to use "XmlSerializer". Unfortunately, that option is not exposed through an UI dialog, so we have to edit the .svcmap file directly)

We might want to continue using old style web reference for those web services. Unfortunately, "Add Web Reference" menu is disabled by default in the projects, unless you already had such reference in the project. In beta 1, there is no way to find this command. We have to downgrade the project to target 2.0 platform to add one web reference and upgrade the project again to add the first web reference. It is very ugly workaround. In CTPs after beta 1, the command can be accessed through the dialog popping up when we click the "advance" button on the "Add Service Reference" dialog. It is not an obvious place to find it, but the menu should be enabled after that, so it only need be done once.