Question

I am going to develope REST(without any framework like SPRING) services which can accept xml. I am going to create XSD for the input xml format.

Now, when client sends some invalid xml which is not as per schema, how should i validate it? Do i need to write a specific code to validate. Can't it get failed in the client side itself?

Previously we had soap service, so if i try to send soap request which is not as per schema, soapui will throw error. The request even will not come to server i guess.

I hope you understood my question, please clarify.

Was it helpful?

Solution

RESTful clients are free to transmit any content they wish to the server, and even try to negotiate different encoding formats like JSON instead of XML. That's part of the power of REST.

It's up to the server to validate that clients send correctly encoded data in the payload, and return a 400-range status code such as 400 - Bad Request if they do not.

You will need to write all your server validation code yourself unless the REST API framework on the server side provides it for you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top