• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

How to study API schemas?

 
Ranch Hand
Posts: 73
1
Python Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, I am expecting to start a new project soon. It will be for writing a little API.
Only thing chosen so far is that clients will send me XML.
I guess I could go with SOAP (still have not been given a full list of requirements)

Anyway, I want to do things properly: using API schemas and XML schema validation (client sends his XML, I compare that to a known schema and return a code if they got the format wrong).

Thing is: I have a very basic idea of what a schema is!
All I know is that you could have a schema document that describes the format of documents created under that type.

Is there a "for dummies"-style book or web page that takes you through API Schemas and XML Schemas from the beginning (understanding what are XML schemas and why are they used) all the way to a decent java project that utilizes some pro-level java tools?
 
Ranch Hand
Posts: 543
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,


In terms of terminology,API's don't have schemas. XML documents have schemas.
Schemas describe what is allowed in an XML document and documents are then validated against a particular schema.  

In general, for an API ,use REST,it is easier and far more common these days.

The API and parsing the xml are exclusive of each other in terms of tasks .
The browser calls the API the API then calls the classes that do the work.
Put those classes in their own package and include your own .

Regarding what you actually have to do with the XML documents:
1) I would suggest creating an interface first for what you want to do with the XML.
2) Create tests for what you expect to happen when various methods get called.
3) Program the implementation classes that use the interface (s) you created.


An interface example:


In terms of ,implementing the interface there are a number of java libraries . That's something you can Google and pick one or try it out.

A native library is jaxb . You might want to start there.

I've had tasks where I've had to manipulate data from XML documents or create xml documents. If you have to parse documents  there are two main classes that I've used DOMParser and SAXParser .

DOMParser is more flexible but requires more memory because it loads the entire document in to memory first. SAXParser goes top to bottom reading the document so it is good for large documents.

After that is implemented and working then start on the API application the client will use . Using interfaces will help you there as well.
That application will use your XML package to do the actual work.
 
Hopefully,this will help you get started .
Good luck ,
Paul
 
Todor Kolev
Ranch Hand
Posts: 73
1
Python Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First and foremost, thanks for taking the time to write a thoughtful answer.

Second, I am hoping for book recommendations and not people providing the knowledge here (which is much appreciated, don't get me wrong!)
 
Sheriff
Posts: 17264
299
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul’s answer is pretty good. I would have taken it and searched for something like “book recommendations good REST API design” because that would probably get me a ton of recommendations.
 
paul nisset
Ranch Hand
Posts: 543
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

In terms of XML, you might want to look at "Java XML and JSON" by Jeff Freisen .
It is pretty good . It was part of a promotion here earlier in the year.

Also, depending on where you live, check out the public  library.
 
Is that a spider in your hair? Here, threaten it with this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic