简体   繁体   中英

Java Web Service Oracle

I have a oracle database with a table tha contains user. I want to create a web service in java to get a user by id. How i do this? I search in the internet but i only get Hello World Tutorials.

Thanks

I would suggest you use Spring-WS they have a few good tutorials and a few good sample applications that you can modify to meet your needs. You can find out more at :

http://static.springsource.org/spring-ws/sites/2.0/

You have to do a few different things:

  1. You should write a simple wsdl to define your web service. This may also require you to write some xml schemas. You can find some examples here: http://www.w3.org/2001/03/14-annotated-WSDL-examples.html . Remember wsdls are simply a description of the webservice you intend to write.

  2. The next step is actually write the web service. This requires you to generate objects that will marshall/unmarshall requests and responses. The SpringWS documentation gives you a few examples how to do that.

  3. Finally you need to write the database level calls.

You really have two problems here:

  1. How to query an Oracle database to get records from the user table for a given id.
  2. How to expose that method to web clients as a web service.

You don't say whether you want SOAP or REST.

I'd recommend Spring for both. Its SimpleJdbcTemplate will make task 1 easy; Spring web services will make it easy to write a contract first SOAP service.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM