GithubHelp home page GithubHelp logo

restwebservice's Introduction

RestWebService

An example of restful + webservice using jersey

DistanceCity -REST WebService developed to measure the distance between two previously registered cities in a database.

Requirements -Tomcat 7 Java Application Server. -Mysql 5.5 database server. -Java 7

How to setup?

1)Configure the database. Run the DistanceCity_DUMP_DATABASE.sql on an instance of MySql5 server installed. (Need admin privileges to create database and tables)

-Default parameters of database connection on webservice. Default parameters* jdbc.user=root jdbc.password=root jdbc.host=localhost jdbc.port=3306 jdbc.database=hub

*The app expects these parameters on connection by default, after run the dump of database creation. If you need change to your custom parameters, modify the file: DistanceCity.war\WEB-INF\classes\database.properties
You can extract and compress again a .war file using 7z (Seven Zip)

2)Deploy the DistanceCity.war. Use the Manager App of Tomcat 7 server to deploy the file into server. After the deploy, restart the server.

3)Testing the webservice. Examples:

JSON response of distance between MANAUS and RIO DE JANEIRO. http://localhost:8080/DistanceCity/city/calculateJSON?city1=MANAUS&city2=RIO%20DE%20JANEIRO {"city1":"MANAUS","city2":"RIO DE JANEIRO","distanceKM":"2850.954576921833","distanceMiles":"1771.5831740992269"}

XML response of distance between MANAUS and RIO DE JANEIRO. http://localhost:8080/DistanceCity/city/calculateXML?city1=MANAUS&city2=RIO%20DE%20JANEIRO MANAUS RIO DE JANEIRO 2850.954576921833 1771.5831740992269

MILES response of distance between MANAUS and RIO DE JANEIRO. http://localhost:8080/DistanceCity/city/distanceMiles?city1=MANAUS&city2=RIO%20DE%20JANEIRO&unit=MI 1771.5831740992269

KM response of distance between MANAUS and RIO DE JANEIRO. http://localhost:8080/DistanceCity/city/distanceMiles?city1=MANAUS&city2=RIO%20DE%20JANEIRO&unit=KM 2850.954576921833

A sample to test only the webservice without database. http://localhost:8080/DistanceCity/city/sample {"id":"1","latitude:":1.000","longitude":"1.000","name":"Manaus"}

Cities availables* MANAUS RIO DE JANEIRO BRASÍLIA SÃO PAULO PORTO ALEGRE

*Remember of word accents to test another cities on webservice. (latin1 charset)

4)Justifications -To implement the webservice was used the API Jersey (https://jersey.java.net/). Simple, small and portable. -To calculate the distance between two points was used the Haversine formula.

Anothers approachs were coonsiderated but discarded a) Google Maps Directions. Need an access to internet to work. As the cities were considerated like two points, the area of cities are inside of uncertainity and the precision of goole maps api would not be necessary. Because this Haversine formula was used.

5)Problems or questions on configuration, contact: +55 15 98107 88881 [email protected] Arllen Lira

restwebservice's People

Contributors

arllenlira avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.