简体   繁体   English

如何在.net中创建服务SOAP Web服务?

[英]how to make a service, SOAP web service in .net?

Please forgive me for this basic and a little theoretical question as I dont know much about web services. 请原谅我这个基本的理论问题,因为我对Web服务了解不多。

I m not refering WCF service, I am reffering simple service in .net / C#. 我没有引用WCF服务,而是使用.net / C#中的简单服务。 I want to know how to know is it soap or rest service ? 我想知道是肥皂还是休息服务?

How we can change this type from Soap to Rest and vice versa ? 如何将这种类型从“肥皂”更改为“休息”,反之亦然?

Thanks 谢谢

XML Web Services (aka classic/legacy ASMX web services) should not be used for active development. XML Web Services(又名经典/传统ASMX Web服务) 应用于主动开发。 If you must, there is a nice walkthrough on MSDN for adding Web references in more recent versions of Visual Studio (> 2005). 如果必须的话, 在MSDN上一个很好的演练,可以在最新版本的Visual Studio(> 2005)中添加Web引用。

On the other hand, if your web service is truly Restful then you won't be able to create the equivalent of a service reference to it. 另一方面,如果您的Web服务确实是Restful,那么您将无法创建与其等效的服务引用。 You'll need to either use the HttpWebRequest , WebClient , or the new HttpClient from .NET 4.5 (also available from the Rest starter kit which is depreciated as well). 您将需要使用.NET 4.5中的HttpWebRequestWebClient或新的HttpClient (也可以从不推荐使用的Rest入门工具包中获得)。


As an alternative if you are looking to implement a client that is able to handle both situations, I would recommend HttpWebRequest to POST to the SOAP (non-WCF) service. 作为替代方案,如果您希望实现能够处理这两种情况的客户端,我建议将HttpWebRequest POST到SOAP(非WCF)服务。 The problem with this method is you'll likely have to wrap the request in the SOAP wrapper yourself. 这种方法的问题是,您可能必须自己将请求包装在SOAP包装器中。 Luckily there are examples of doing so on the net that you can at least use as a starting point. 幸运的是,网上至少有一些这样做的例子 ,您至少可以以此为起点。

ASMX services are build upon SOAP. ASMX服务建立在SOAP之上。 REST is simply a HTTP based, You can access(or call) your business resources the way you access the normal URLs. REST只是基于HTTP的,您可以通过访问普通URL的方式访问(或调用)您的业务资源。

For ex in products catalog system, by using asmx you create set of functions to add,update,delete products. 对于产品目录中的ex,通过使用asmx,您可以创建一组用于添加,更新,删除产品的功能。 like addProduct(),updateProduct, etc.. 如addProduct(),updateProduct等。

But in REST, you will be having single point of access, like http:\\mysystem\\prodcuts. 但是在REST中,您将具有单点访问,例如http:\\ mysystem \\ prodcuts。 To retrieve,add,update,delete products, you will be using respective HTTP verbs (GET,POST,PUT,DELETE) on the same URL. 要检索,添加,更新,删除产品,您将在同一URL上使用相应的HTTP动词(GET,POST,PUT,DELETE)。

so,technically it's not possible to convert asmx(SOAP) service to rest... 因此,从技术上讲,不可能将asmx(SOAP)服务转换为rest ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM