问题描述:

I need to create a web service which can connect to database to retrieve a result-set and respond back in XML.

Which is the best way in terms of scalability & speed of development to achieve the above?

And also i should be able to generate client code without Axis automatically in Eclipse by using the WSDL of the web-service I create.

Please point me to some good, complete tutorials.

Thanks

网友答案:

First, do you need SOAP, is it in your requirements? If not, consider using REST via JAX-RX (Jersey), JAXB, and JPA for the database; I've had phenomenal results.

网友答案:

A tutoiral for the XML part (Jaxb)

Another tutorial for more details.

a quick overview about jax ws

In general you load your data as beans with jpa/hibernate but add xml annotations for the automatic marshelling/unmarshelling to build the response xml.

The rest is done (the transmission and the incoming call) with jax ws. Normally you only have to implement the endpoint, the rest can be generated by the wsdl.

Step by step:

  1. start like usual implementing your web app infra structure (data beans, dao, services)
  2. add xml annotations (mind the dangerous backrefrences obj1 references obj2 references obj1, use XMLTransient annotation for members AND getter methods to avoid those references)
  3. write the wsdl/get the wsdl from the customer or partner
  4. generate the classes
  5. implement the endpoint (the actual functionality)
  6. repeat steps 2 to 5 until your customes stops changing the specificiation ;-)
相关阅读:
Top