I am having the next problem:
I want to log the SOAP requests/responses that land on my web service (server side). Trying to configure my web service in the wsdd file. I am always landing on pages like the next one:
How to use the org.apache.axis.handlers.LogHandler
Which recommends to configure the Apeche Axis LogHandler to log the request/response. That is not valid for me, since a)there is no way to link the log4j there, and b)I just am not able to make it work.
Does anyone know a way to make my log4j to log the request/responses?
A solution to log the Axis Faults is extend the OnFault method :
It is also mandatory to set the handler in the global configuration request flow, in the wsdd file will be something like this :
You need to add an Axis logger in your
log4.xml
configuration file, like below:someLogAppender
may be an existing Log4J appender, or you may want to define a dedicated one, like below:Save this file as "client-config.wsdd" in the working directory as you do for log4j.properties .
If you don't want to alter any code and debug your axis web service client, you can follow this method to log all incoming and outgoing soap messages.
I know its a old thread, but may be useful for people looking for answers.
For AXIS-1 Server side logging, update your
server-config.wsdd
like below.server-config.wsdd
is underWEB-INF
folder of your war file.A new handler for log. The file name along with path is configurable.
You can also use the
LogHandler.writeToConsole
parameter with the value as"true"
to log in your console log.Then update the
<globalConfiguration>
section to haveIf the
requestFlow
andresponseFlow
contains other handlers ,put the log as the first handler.This should be only used for debugging purpose not for production. Since the logging is naive and do the normal write operation on the file without any buffer. Secondly, the log file will grow to GB's since there is no rollover mechanism.
For AXIS-1 Client Side logging, update your
client-config.wsdd
like below. Theclient-config.wsdd
should go into yourclasspath
directly under a root folder configured in theclasspath
not in any sub-folders. The best location is the same directory where yourlog4j.xml
orlog4j.properties
file is present(Thanks to #MukeshKoshyM post above).The same issue mentioned for server side logging is applicable for client side as well.
For production, write your own log handler by extending
org.apache.axis.handlers.BasicHandler
and configure the class file in the handler. Please look the above answer from #raspayu to configure your own. To log the faults override thepublic void onFault(MessageContext msgContext)
method in your Handler.Axis by default is checking for file client-config.wsdd. We need to keep this file in the location same as log4j.xml or log4j.properties. Log file will be generated at the location specified on log handeller. Ensure the folder structure exists.
mukesh
So after hours or Googling out there in the web, I decided to get adventurous and program my own handler. Is much easier than expected.
I made a class that extends the abstract class BasicHandler (org.apache.axis.handlers.BasicHandler), and implements the invoke method loging the request or the response. Here is my class, which I have baptized as SOAPLogHandler :
The idea is, to log first the request, and when processed, log the response. So, in the server-config.wsdd (or the wsdd file from your client if you are in the client side), we have to add a handler pointing to that class, and configure it to uses in the request/response chain:
1st add the handler
2nd add the use of that handler to the request/response from the http transport (focus on the log handler)
With that, the magic should be done, and you should receive a pretty log from the request/responses!
Disclaimer: I am not really sure from what will happend if you use some kind of SOAP multipart thing.