Web服务VS Web应用程序 [英] Web Service vs Web Application

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

问题描述

我知道这是一个老问题,必须已经已经回答了一百次,但我无法找到尚未一个满意的答复。

I know this is an old question and must have been answered hundred times already, but I am not able to find a satisfactory response as yet.

我创建获取数据,将其他应用程序(手机/网络)使用的应用程序。现在我有2个选择:

I am creating an application which will be used by other applications (mobile/ web) to fetch the data. Now I have 2 options:


  1. 创建我的应用程序作为一个简单的Web应用程序。

  2. 创建一个Web服务。

一个Web服务看起来更加复杂,其中的任何客户端将提供一个指定格式(SOAP / REST)的数据和我的应用程序将解析请求,并返回由客户要求的数据。如何数据将被用来不是我的应用程序的问题。

A web service looks more sophisticated where any client will provide the data in a specified format (SOAP/ REST) and my app will parse the request and return the data asked by client. How the data will be used is not my app's problem.

我的问题是,同样可以通过简单的Web应用程序接受XML格式的请求,并与XML响应响应来实现。直觉是,Web服务将是一个更好的方式去为这种服务,我们不知道谁一切都将使用它。但是否有使用Web服务通过一个简单的Web应用程序的任何具体的好处?

My question is that same can be achieved by a simple web app accepting the request in XML format and responding with an XML response. Gut feeling is that a web service will be a better way to go for this kind of service where we are not sure who all will be using it. But are there any specific advantages of using a web service over a simple web app?

推荐答案

在低层次的Web应用程序和Web服务都还挺同样的事情。他们都在operatate HTTP(S)。 SOAP只是一个XML定义良好的版本。 REST是有点儿只是HTTP。如果你愿意,你可以做一个Web应用程序看起来像Web服务,反之亦然。

At a low level web applications and web services are kinda the same thing. They both operatate over http(s). SOAP is just a well defined version of XML. REST is kinda just HTTP. If you wanted to, you could make a web application look like web services and visa versa.

的主要区别是根据你所使用的平台上内部开发的选项。如果,例如,您正在使用的Visual Studio然后添加一个WCF服务应用程序会给你一个项目,该项目是在默认情况下对WCF面向。但是,选择任何其他应用程序类型将不会从添加Web服务阻止你。

The main difference would be internal development options based on the platform you are using. If, for example, you are using Visual Studio then adding a WCF Service Application will give you a project which is by default geared towards WCF. But choosing any other application type won't stop you from adding Web Services.

使用SOAP一般比普通的旧XML这些原因一个更好的选择:

Using SOAP is generally a better option than plain old xml for these reasons:


  • 您的用户将期待它,并有可能知道如何已经阅读。

  • Your users will be expecting it, and are likely to know how to read it already.

您用户的开发环境,将很可能都知道SOAP和能够跨preT它的开箱。 (如果您提供一个WSDL文件那么很多用户将可以使用脚本生成在几秒钟内你的类。)

Your users' development environments will likely know all about SOAP and be able to interpret it out of the box. (If you provide a WSDL file then many users will be able to use a script to generate your classes in seconds.)

您的消息更容易被明确界定。我的工作在那里的另一面已经定义自己的随机XML结构的那一刻一个项目,这是一起工作的噩梦。我从来没有真正知道会发生什么,有其不同的信息类型之间很少具有一致性。至少如果他们同意遵守SOAP话,我可能有一个更容易的时间间preting他们的消息。

Your messages are more likely to be well defined. I am working on a project at the moment where the other side have defined their own random XML structure and it is a nightmare to work with. I never really know what to expect, and there is little consistency between their different message types. At least if they had agreed to conform to SOAP then I might have had a much easier time interpreting their messages.

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

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