Should the REST service expose XSD for XML responses?

We created a REST service, which, depending on the accept header, will return XML or JSON to the client, or XML or JSON will be accepted depending on the content type header.

Now, a recent integrator has asked us if we have an XSD schema for our XML responses and requests.

Is this common practice when developing REST services?

+4
source share
3 answers

It is common practice to provide subscribers of any service, including REST, with an interface definition for this service. If you have an XML interface, some XML schema ( XSD , RELAX NG , Schematron , etc.) is a great way to define a request and response . In addition to providing documentation, it can be used by checking parsers to catch violations of the declared interface.

You may also consider creating JSON Schema definitions for your JSON interface. It can provide some of the same benefits as an XML schema, however, perhaps this is less "common practice" than XML schemas for XML.

+6

, .

, .

xsd - , . (., , http://martinfowler.com/bliki/TolerantReader.html). , , . , , . , .

SOAP wsdl xsd. REST , .

xsd . , ( "" ), , , ( , ). xsd, , , .

( - , , , . , xpath xml xsd)

+4

Why not? If you are communicating via XML, you can add an attribute schemaLocationto specify the URL of the schema. Otherwise, how can the client validate the XML server and correctly form its own queries?

+2
source

All Articles