Web 参考与服务参考 [英] Web Reference vs. Service Reference

查看:28
本文介绍了Web 参考与服务参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚用 Paypal 撞到了一堵巨大的砖墙.我创建了一个常规的 C# 项目来使用它们的 WSDL 创建一些包装类.

I just hit a huge brick wall with Paypal. I had created a regular C# project to create some wrapper classes using their WSDL.

如果您创建一个非 Web 项目,添加 wsdl 的唯一选项是 Web 服务引用.这构建了与 Web 引用相同的一组代理类,但实际上并非如此..它增加了甚至 PayPal 人员都不知道的更多内容.

If you create a non-web project, the only option you get to add a wsdl is a Web Service Reference. And this builds kinda the same set of proxy classes as a Web Reference would but not really..it adds more that even the PayPal guys are not aware of.

所以我一直在这个代理类列表中寻找正确的接口以用作服务 (SoapBinding),但 PayPalAPIAASoapBinding 不在那里,我一直告诉我们的 PayPal 联系点.

So I was this entire time looking for the right Interface in this list of proxy classes to use as the service (SoapBinding) and the PayPalAPIAASoapBinding was not there I kept telling our PayPal point in contact.

我只能看到以下 2 个接口,这些接口在我看来是我需要使用的,因为我没有看到您可以在基于 Web 参考的服务参考中看到的 PayPalAPIAASoapBinding:

I could only see the following 2 Interfaces that appeared to me what I needed to use since I did not see a PayPalAPIAASoapBinding which you CAN see in a Web Reference based service reference:

PayPalAPIAAInterfaceClient
PayPalAPIInterfaceClient 

所以我想通了哦,我可能已经创建了一个服务引用与一个 Web 引用,其中 Web 引用是 Web 项目中的一个选项.但我不希望我的服务引用与我的 Web 项目紧密耦合.这就是我创建 C# 项目的原因.

So I figured out oh, I probably had created a Service Reference vs. a Web Reference which Web Reference is an option in a Web project. But I don't want my service reference tightly coupled to my web project. So that's why I created the C# Project.

那么服务引用与 Web 引用到底是什么?如果服务引用会给我一个循环并为我提供一组与 Web 引用不同的接口,我应该如何将其分离到另一个项目中?

So what the heck is a Service Reference vs. Web Reference? And how am I supposed to separate this out into anther project if Service Reference is going to throw me a loop and give me a set of different interfaces than a Web Reference would?

此外,更令人困惑的是,VS 2008 有一个 Web 服务应用程序项目.

Also, to make things even MORE confusing, VS 2008 has a Web Service Application project.

那我用什么?我们正在使用 .NET 3.5 框架,但我们还没有准备好迁移到 WCF.那么即使不使用 WCF 或什么,我仍然可以使用新的服务引用吗?如果您使用的是 .NET 3.5 而不是 WCF 并且您仍然想要做基本的 Web 服务,您是否仍然走服务引用路线而不使用 WCF 框架?这意味着它仍然可以像 .NET 2.0 Web 参考一样使用,只是您将获得完全不同的 WSDL 代?

So what do I use? We're using the .NET 3.5 framework and we're not ready to move to WCF. So can I still use the new Service Reference even if not using WCF or what? IF you're using .NET 3.5 and not WCF yet and you still want to do basic web services, do you still go the Service Reference route and just not use the WCF framework? Meaning can it be used like a .NET 2.0 Web Reference still, just that you're going to get an entirely different generation of the WSDL?

推荐答案

添加 Web 引用 是旧式的、已弃用的 ASP.NET 网络服务 (ASMX) 技术(仅使用 XmlSerializer 来处理您的内容) - 如果你这样做,你会得到一个 ASMX 网络服务的 ASMX 客户端.您几乎可以在任何项目中执行此操作(Web 应用程序、网站、控制台应用程序、Winforms - 您可以随意命名).

Add Web Reference is the old-style, deprecated ASP.NET webservices (ASMX) technology (using only the XmlSerializer for your stuff) - if you do this, you get an ASMX client for an ASMX web service. You can do this in just about any project (Web App, Web Site, Console App, Winforms - you name it).

添加服务引用是一种新的方法,它添加了一个 WCF 服务引用,它为您提供了一个更先进、更灵活的服务模型,而不仅仅是简单的旧 ASMX 东西.

Add Service Reference is the new way of doing it, adding a WCF service reference, which gives you a much more advanced, much more flexible service model than just plain old ASMX stuff.

由于您还没有准备好迁移到 WCF,您仍然可以添加旧式 Web 引用,如果您确实必须:当您执行添加服务引用"时,在出现的对话框中,单击按钮左角的[高级]按钮:

Since you're not ready to move to WCF, you can also still add the old-style web reference, if you really must: when you do a "Add Service Reference", on the dialog that comes up, click on the [Advanced] button in the button left corner:

在出现的下一个对话框中,选择底部的 [Add Web Reference] 按钮.

and on the next dialog that comes up, pick the [Add Web Reference] button at the bottom.

这篇关于Web 参考与服务参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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