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开发者_如何学Python 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:
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.
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.
Finally you need to write the database level calls.
You really have two problems here:
- How to query an Oracle database to get records from the user table for a given id.
- 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.
精彩评论