The mentor suggested breaking my project into three modules. The first is DAO, the second is API (XSD), the third is WEB (service, controller). The first two are clear. But what is XSD, and why is it needed, and I don’t know how to use it? And the mentor spoke very superficially, without really explaining anything.
2 answers
You have XSD mentioned in the API context. Your mentor probably meant that the service should, in the form of XSD, provide information about the format of messages that can be shared with it.
For example, there is an XML of the form:
<data> <field1>abc</field1> <field2>1<field2> </data> It can be assumed that the element field1 is of type string (string). But what type of field2 ? String or number? If the number, then whole or real, signed or unsigned? It cannot be determined from the message itself. All this and other information is contained in XSD.
Of course, this is correctly called Xml Schema. And xsd is the file extension of this format.
Moreover, there are many other schemes that describe data transfer formats and methods of interaction between the service and the client. In particular, WSDL, WADL, SOAP and others. They describe not only the types of data, but also the methods that the service can perform and so on. Often they are called simply schemas, and hence some confusion with XSD.
Using these schemes, a set of classes (DTO / POJO) can be automatically generated in the programming language used, be it Java or any other. As well as the code of the client, immediately containing methods for accessing the service. It is very convenient, but, unfortunately, there are too many standards of such schemes and different software manufacturers support different ones.
- That is, Xml Schema is a format for exchanging information between a client and a server. If I correctly understood something similar to JSON? Or am I misunderstanding something? - JVic
- @ Victor - JSON and XML are data . A schema is a description of the data, a data format . - Alexander Petrov
Most likely it was meant to develop an information exchange API through the transfer of an XML structure.
Those. in fact, in order to interact with your service (in theory, this is a back-end) - then you need to send you XML (for example) by means of POST / GET and so on.
Well, the service must “respond” to you through the same format, for example.
Such a module can be a set of classes (with annotations) that come to you in the form of text, are converted to an object on the controller. Well, back from the object to the text of the form XML.
- And with the help of XSD, most likely, a valid XML file is checked or not (whether the file structure is correct). - Sanek Zhitnik
- Right! How do popular frameworks like Spring come? XML - for use / configuration, XSD schema - for validating these XML themselves - Chubatiy
- That is, Xml Schema is a format for exchanging information between a client and a server. If I correctly understood something similar to JSON? Or am I misunderstanding something? - JVic
XSD- Xml schema definition, language for describing the structure of thexmldocument. - hotfix