简体   繁体   English

XSD 和 WSDL 有什么区别?

[英]What is the difference between XSD and WSDL?

What is the difference between an XML Schema and WSDL ? XML SchemaWSDL之间有什么区别?

The difference I noticed is that WSDL contains XSD and in WSDL we can declare operations, but not in XSD .我注意到的不同之处在于WSDL包含XSD并且在WSDL我们可以声明操作,但不能在XSD声明。 Is that correct?那是正确的吗?

WSDL (Web Services Description Language) describes your service and its operations - what is the service called, which methods does it offer, what kind of in parameters and return values do these methods have? WSDL (Web 服务描述语言)描述您的服务及其操作 - 服务被称为什么,它提供哪些方法,这些方法具有哪些类型的参数和返回值?

It's a description of the behavior of the service - it's functionality.它是对服务行为的描述 - 它是功能。

XSD (Xml Schema Definition) describes the static structure of the complex data types being exchanged by those service methods. XSD (Xml Schema Definition)描述了由这些服务方法交换的复杂数据类型的静态结构。 It describes the types, their fields, any restriction on those fields (like max length or a regex pattern) and so forth.它描述了类型、它们的字段、对这些字段的任何限制(如最大长度或正则表达式模式)等等。

It's a description of datatypes and thus static properties of the service - it's about data.它是对数据类型的描述,因此是服务的静态属性 - 它与数据有关。

XSD defines a schema which is a definition of how an XML document can be structured. XSD 定义了一个架构,它定义了 XML 文档的结构。 You can use it to check that a given XML document is valid and follows the rules you've laid out in the schema.您可以使用它来检查给定的 XML 文档是否有效并遵循您在架构中制定的规则。

WSDL is a XML document that describes a web service. WSDL 是描述 Web 服务的 XML 文档。 It shows which operations are available and how data should be structured to send to those operations.它显示了哪些操作可用以及应如何构造数据以发送到这些操作。

WSDL documents have an associated XSD that show what is valid to put in a WSDL document. WSDL 文档有一个关联的 XSD,用于显示可以放入 WSDL 文档的有效内容。

XSD : XML Schema Definition. XSD:XML 架构定义。

XML : eXtensible Markup Language. XML:可扩展标记语言。

WSDL : Web Service Definition Language. WSDL:Web 服务定义语言。

I am not going to answer in technical terms.我不会用技术术语来回答。 I am aiming this explanation at beginners.我是针对初学者的这个解释。

It is not easy to communicate between two different applications that are developed using two different technologies.在使用两种不同技术开发的两个不同应用程序之间进行通信并不容易。 For example, a company in Chicago might develop a web application using Java and another company in New York might develop an application in C# and when these two companies decided to share information then XML comes into picture.例如,芝加哥的一家公司可能使用 Java 开发 Web 应用程序,而纽约的另一家公司可能使用 C# 开发应用程序,当这两家公司决定共享信息时,XML 就出现了。 It helps to store and transport data between two different applications that are developed using different technologies.它有助于在使用不同技术开发的两个不同应用程序之间存储和传输数据。 Note: It is not limited to a programming language, please do research on the information transportation between two different apps.注意:不限于编程语言,请研究两个不同应用程序之间的信息传输。

XSD is a schema definition. XSD 是模式定义。 By that what I mean is, it is telling users to develop their XML in such a schema.我的意思是,它告诉用户在这样的模式中开发他们的 XML。 Please see below images, and please watch closely with "load-on-startup" element and its type which is integer.请看下面的图片,请密切注意“load-on-startup”元素及其整数类型。 In the XSD image you can see it is meant to be integer value for the "load-on-startup" and hence when user created his/her XML they passed an int value to that particular element.在 XSD 图像中,您可以看到它是“启动时加载”的整数值,因此当用户创建他/她的 XML 时,他们将一个 int 值传递给该特定元素。 As a reminder, XSD is a schema and style whereas XML is a form to communicate with another application or system.提醒一下,XSD 是一种模式和样式,而 XML 是一种与另一个应用程序或系统进行通信的形式。 One has to see XSD and create XML in such a way or else it won't communicate with another application or system which has been developed with a different technology.必须以这种方式查看 XSD 并创建 XML,否则它将无法与使用不同技术开发的另一个应用程序或系统进行通信。 A company in Chicago provides a XSD template for a company in Texas to write or generate their XML in the given XSD format.芝加哥的一家公司为德克萨斯州的一家公司提供了一个 XSD 模板,用于以给定的 XSD 格式编写或生成他们的 XML。 If the company in Texas failed to adhere with those rules or schema mentioned in XSD then it is impossible to expect correct information from the company in Chicago.如果德克萨斯州的公司未能遵守 XSD 中提到的那些规则或模式,那么就不可能期望芝加哥公司提供正确的信息。 There is so much to do after the above said story, which an amateur or newbie have to know while coding for some thing like I said above.在上述故事之后还有很多事情要做,业余爱好者或新手在为我上面所说的某些事情编码时必须了解这些。 If you really want to know what happens later then it is better to sit with senior software engineers who actually developed web services.如果您真的想知道以后会发生什么,那么最好与实际开发 Web 服务的高级软件工程师坐在一起。 Next comes WSDL, please follow the images and try to figure out where the WSDL will fit in.接下来是 WSDL,请按照图片并尝试找出 WSDL 适合的位置。

***************========Below is partial XML image ==========*************** ***************========以下是部分 XML 图像 ============************ ***XML 图像部分

***************========Below is partial XSD image ==========*************** ***************========以下是部分 XSD 图像 ==========************ ***

XSD 图像部分

***************========Below is the partial WSDL image =======************* ***************========以下是部分 WSDL 图像 ========*************

WSDL 图像部分

I had to create a sample WSDL for a web service called Book.我必须为名为 Book 的 Web 服务创建一个示例 WSDL。 Note, it is an XSD but you have to call it WSDL (Web Service Definition Language) because it is very specific for Web Services.请注意,它是一个 XSD,但您必须将其称为 WSDL(Web 服务定义语言),因为它非常特定于 Web 服务。 The above WSDL (or in other words XSD) is created for a class called Book.java and it has created a SOAP service.上面的 WSDL(或换句话说 XSD)是为一个名为 Book.java 的类创建的,它已经创建了一个 SOAP 服务。 How the SOAP web service created it is a different topic. SOAP Web 服务如何创建它是一个不同的主题。 One has to write a Java class and before executing it create as a web service the user has to make sure Axis2 API is installed and Tomcat to host web service is in place.必须编写一个 Java 类,并在执行它之前将其创建为 Web 服务,用户必须确保已安装 Axis2 API 并且托管 Web 服务的 Tomcat 已就位。

As a servicer (the one who allows others (clients) to access information or data from their systems ) actually gives the client (the one who needs to use servicer information or data) complete access to data through a Web Service, because no company on the earth willing to expose their Database for outsiders.作为服务商(允许其他人(客户)从他们的系统访问信息或数据的人)实际上让客户(需要使用服务商信息或数据的人)通过 Web 服务完全访问数据,因为没有公司在地球愿意向外界公开他们的数据库。 Like my company, decided to give some information about products via Web Services, hence we had to create XSD template and pass-on to few of our clients who wants to work with us.像我的公司一样,决定通过 Web 服务提供有关产品的一些信息,因此我们必须创建 XSD 模板并将其传递给希望与我们合作的少数客户。 They have to write some code to make complete use of the given XSD and make Web Service calls to fetch data from servicer and convert data returned into their suitable requirement and then display or publish data or information about the product on their website.他们必须编写一些代码来充分利用给定的 XSD 并进行 Web 服务调用以从服务商获取数据并将返回的数据转换为合适的需求,然后在他们的网站上显示或发布有关产品的数据或信息。 A simple example would be FLIGHT Ticket booking.一个简单的例子是机票预订。 An airline will let third parties to use flight data on their site for ticket sales.航空公司将允许第三方使用其网站上的航班数据进行机票销售。 But again there is much more to it, it is just not letting third party flight ticket agent to sell tickets, there will be synchronize and security in place.但还有很多,只是不让第三方机票代理出售机票,会有同步和安全到位。 If there is no sync then there is 100 % chances more than 1 customer might buy same flight ticket from various sources.如果没有同步,那么 100% 以上的客户可能会从不同来源购买同一张机票。

I am hoping experts will contribute to my answer.我希望专家们为我的答案做出贡献。 It is really hard for newbie or novice to understand XML, XSD and then to work on Web Services.对于新手或新手来说,理解 XML、XSD 并在 Web 服务上工作真的很困难。

XSD 用于验证文档,并包含有关 XML 的元数据,而 WSDL 用于描述 Web 服务位置和操作。

XSD (XML schema definition) defines the element in an XML document. XSD(XML 模式定义)定义 XML 文档中的元素。 It can be used to verify if the elements in the xml document adheres to the description in which the content is to be placed.它可用于验证 xml 文档中的元素是否符合要放置内容的描述。 While wsdl is specific type of XML document which describes the web service. wsdl 是描述 Web 服务的特定类型的 XML 文档。 WSDL itself adheres to a XSD. WSDL 本身遵循 XSD。

WSDL - It contains the Operation such as Methods which a webservice provides.and these method can accept simple data types such as int,float etc and complex data types such as objects ,vectors, arrays etc. so mapping this to an xml datatype xsd are used. WSDL - 它包含诸如 Web 服务提供的方法之类的操作。这些方法可以接受简单数据类型(例如 int、float 等)和复杂数据类型(例如对象、向量、数组等),因此将其映射到 xml 数据类型 xsd 是使用。 and based upon the xsd an user who wants to acccess webservice from different platform can provide the data appropriately.并且基于xsd,想要从不同平台访问webservice的用户可以适当地提供数据。

Refer : ayazroomy-java.blogspot.com to read about basics of webservice.请参阅:ayazroomy-java.blogspot.com 以阅读有关 Web 服务的基础知识。

If someone is looking for analogy , this answer might be helpful.如果有人正在寻找类比,这个答案可能会有所帮助。

WSDL is like 'SHOW TABLE STATUS' command in mysql. WSDL 就像 mysql 中的“SHOW TABLE STATUS”命令。 It defines all the elements(request type, response type, format of URL to hit request,etc.,) which should be part of XML.它定义了所有应该是 XML 一部分的元素(请求类型、响应类型、命中请求的 URL 格式等)。 By definition I mean: 1) Names of request or response 2) What should be treated as input , what should be treated as output.根据定义,我的意思是:1)请求或响应的名称 2)什么应该被视为输入,什么应该被视为输出。

XSD is like DESCRIBE command in mysql. XSD 就像 mysql 中的 DESCRIBE 命令。 It tells what all variables and their types, a request and response contains.它说明所有变量及其类型、请求和响应包含的内容。

XSD is schema for WSDL file. XSD 是 WSDL 文件的架构。 XSD contain datatypes for WSDL. XSD 包含 WSDL 的数据类型。 Element declared in XSD is valid to use in WSDL file.在 XSD 中声明的元素在 WSDL 文件中使用是有效的。 We can Check WSDL against XSD to check out web service WSDL is valid or not.我们可以根据 XSD 检查 WSDL 来检查 Web 服务 WSDL 是否有效。

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

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