xml2jsonp proxy server
Basic implementation of xml to jsonp proxy server. Implemented with Java Servlets.
Download
xml2json.war - web application archive that can be deployed to any JEE servlet container (e.g. Tomcat) or application server.
Source code: xml2jsonp.zip.
Build and run from source
Apache maven is used to build and run the application. Steps:
- download and install maven
- download and extract xml2jsonp.zip
- go to the extracted directory and from command line run 'mvn jetty6:run' (this will compile the source code, create a war file, download and start embedded servlet container - jetty, deploy and run the proxy server)
- url of the proxy server is: http://<hostname>:8080/xml2jsonp/Xml2JsonpProxyServlet
Dependencies
Input
Only HTTP GET method is supported.
mandatory:
- 'url' - url of the target server that outputs XML (e.g. RSS or Atom)
- 'callback' - javascript callback function name as defined in jsonp
optional:
- 'cookie' - name value pair that will be send to the target server as a cookie; the request can contain zero, one or many 'cookie' parameters
Output
Possible improvements
Whole xml document is loaded into memory. It is then transformed to json format. This won't scale too well with increasing number of users and bigger xml documents. Better solution would be to stream the xml document and transform it incrementally.