A
A
Artem2015-08-25 19:10:42
Java
Artem, 2015-08-25 19:10:42

How to log a request / response of a web service to the database (in particular, jax-ws on tomcat / glassfish)?

I am doing a test.
Developed a simple jax-ws web service under Tomcat.

One of the task items: "Response and request (of a web service) - log to the database".
I figured out how to intercept SOAP messages using HandlerChain.
What to do next with the SOAP message is not entirely clear.

Maybe they mean some common, "generally accepted" practice (reception) of logging a request / response of a web service to the database? Or is it not quite a trivial task and you need to think through everything yourself?
(I understand that it is most logical to ask those who created the task, but suddenly someone will say "this is a very trivial moment and this is usually done this way") I

just started learning web services, java EE and everything else (although more general basic prior knowledge).
And now, thinking about this subtask, I did not understand the following questions:
1) Is there some kind of default database in Tomcat (it starts up right away, is configured, etc. - you can work with it right away), which can be used for logging?
Or do I need to deploy it myself on the server?
Or is there only an opportunity to organize interaction with some external database?
2) What do you need when logging to enter the message itself (or only data), system time / date, the second side (client)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bromzh, 2015-08-25
@JustSokol

Tomcat does not support everything from JavaEE, it is only a servlet container, not a full-fledged ApplicationServer. So either use TomcatEE or other servers (I recommend WildFly).
You can read more about logging to the database here .
You can also use interceptors (interceptors). This is part of JavaEE, you can intercept bean methods. More here and on google.
There is no database in Tomcat, everything is at a minimum there. To connect the database, you need to add jar files with the JPA implementation yourself, configure the database yourself in the application. At the same time, JTA and other things will be difficult to connect and configure, because Tomcat is not an ApplicationServer. It is better to take WildFly. There is already one DataSource by default (the database is in RAM, it is cleared after the server is restarted), and it is easy to connect a new source to the web server itself.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question