Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Ws Wiki" for change 
notification.

The following page has been changed by RichardUnger:
http://wiki.apache.org/ws/FrontPage/Axis/Logging/In_Memory_Logging

New page:
[[TableOfContents]]

[[AttachList(FrontPage/Axis/DynamicSSLConfig)]]

This page describes a HTTP logging facility created to aid in Axis development.

See also ["FrontPage/Axis/DynamicSSLConfig"] for more information about the SSL 
setup. [[BR]]
See also ["FrontPage/Axis/Logging/Logging with SSL"] for more information about 
logging HTTP messages.

=== The Problem ===

Axis comes with a !LogHandler which can be used to dump SOAP requests/responses 
to a log file. Normally, this works very well, but has the following 
shortcomings:

 * All logs are written to the same file, to get at the trace you need requires 
finding it in the file, and then copy and pasting it into another program for 
formatting
 * Logs are not accessible to the application that created them

=== The Solution ===

A new Axis Handler was written for logging. Essentially, this is modelled on 
the original !LogHandler class, with the following differences:

 * The logs are created in seperate files, each request and each response is 
stored in a seperate file
 * The last request and response are retained (as strings) within the Handler 
class. Accessor methods are provided to retrieve these strings

This allows an application to access the handler, and then access the logs

=== Usage / Configuration ===

To use the logging facility, add the classes downloaded from this page to your 
web service client application.

The following is a sample of using the in memory SOAP logging:

{{{#!java
// create config
boolean logging = true; // activate logging
SSLClientAxisEngineConfig axisConfig = new SSLClientAxisEngineConfig();
axisConfig.setKeystore("/path/to/clientkey.p12");
axisConfig.setKeystoreType("PKCS12");
axisConfig.setKeystorePassword("changeit");
axisConfig.setTruststore("/path/to/truststore.jks");
axisConfig.setTruststoreType("JKS");
axisConfig.setTruststorePassword("changeit");
if (logging)
    axisConfig.setDebugBaseDir("/path/to/logs");
axisConfig.initialize(logging);
// initialize service
URL soapURL = new URL("https://myserver.com/myapp/services/mywebserviceport";);
MyWebServiceServiceLocator locator = new MyServiceLocator(axisConfig);
MyWebServicePort port = locator.getMyWebServicePort(soapURL);
MyWebServiceBindingStub stub = (MyWebServiceBindingStub) port;
// make a call to the webservice (assume no params for this operation)
MyResultType result = stub.myoperation1();
}}}

Note: In the example above it is assumed that you have created the client stubs 
for the web service "!MyWebService" using the Axis WSD!L2Java tool.

After the call to myoperation() the log directory specified should contain 2 
more files, one with "request" in the filename (the request), and one with 
"response" in the filename, the response.

To access the logs within the application, do something like this:

{{{#!java
AxisDebugLogHandler handler = axisConfig.getLogHandler();
String reqStr = handler.getReqMessage();
String respStr = handler.getRespMessage();
}}}

You can now work with the SOAP message strings within your application, for 
example to log them to your own integrated logs, or display them to the user, 
or send them as part of an automated bug report, etc...

=== Shortcomings ===

 * Logging occurs when response is received - no response probably means no logs
 * SOAP logs do not contain attachments or HTTP headers
 * Filenames for logfiles not configurable
 * /!\ Do not use in production setups! This code is ok for development, but 
logging should be switched off in productive setups

=== Comments, Feedback, Support ===

This code is supplied back to the apache foundation, without any support or 
warranty. Use at your own risk. The author and his employer assume no 
responsibility for damages resulting in the use of this code or these 
instructions.

Feel free to use the code in any way you want but do not expect support.

Should you have questions about the code, please feel free to contact me (the 
Author) at: runger --AT-- aon.at 







---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to