What is XSD? what is it eaten with?

The mentor suggested to divide my project into three modules. The first is the DAO, the second is the API (XSD), and the third is the WEB(service, controller). The first two are clear. But what is XSD, and why is it needed, and how to use it, I do not know? And the mentor told me very superficially, without really explaining anything.

 1
Author: JVic, 2016-11-09

2 answers

You have XSD mentioned in the API context. Your mentor probably meant that the service should provide information in the form of XSD about the format of messages that can be exchanged with it.

For example, there is an XML of the form:

<data>
    <field1>abc</field1>
    <field2>1<field2>
</data>

We can assume that the field1 element is of the string type. But what type of field2? String or number? If a number, is it integer or real, signed or unsigned? This cannot be determined from the message itself. All this and other information is contained in in XSD.

Of course, this is correctly called Xml Schema. And xsd is a file extension of this format.

Moreover, there are many other schemes that describe the data transfer formats and ways of interaction between the service and the client. In particular, WSDL, WADL, SOAP, and others. They describe not only the data types, but also the methods that the service can perform, and so on. They are often referred to simply as schemas, and hence some confusion with XSD.

According to these schemes, it can automatically generate a set of classes (DTO/POJO) in the programming language used, whether Java or any other. As well as the code of the client itself, which immediately contains methods for accessing the service. This is very convenient, but unfortunately, there are too many standards for such schemes and different software manufacturers support different ones.

 4
Author: Alexander Petrov, 2016-11-10 15:10:47

Most likely, it was meant to develop an API for exchanging information by passing an XML structure.

That is, in fact, in order to interact with your service(in theory, this is the back - end), you need to send XML to you via POST/GET, etc.requests(for example).

Well, the service should "answer" you using the same format, for example.

Such a module can be a set of classes (with annotations) that come to you as text, are converted on the controller to object. Well, and back from the object to the XML text.

 2
Author: Chubatiy, 2016-11-10 12:46:29