Search code examples
cgsoap

Logging xml content in http request


Currently I am working on an application and need to log all the xml content in http request/response. My application is based on C and use gsoap. I have very less experience on working with gsoap. Went through the gsoap userguide also some answers on stackoverflow which suggests to use plugins and refer to plugin.h and plugin.c files. I went through all of them but was not able to understand how to proceed.

This is needed for both http and https request/response.


Solution

  • Register the message logging plugin declared in gsoap/plugin/logging.h as follows:

    #include "plugin/logging.h"
    
    struct soap *ctx = soap_new();
    
    // Register the plugin
    soap_register_plugin(ctx, logging);
    
    // Change logging destinations to stdout (or another open FILE*):
    soap_set_logging_inbound(ctx, stdout);
    soap_set_logging_outbound(ctx, stdout);
    ...
    

    Then compile your code together with gsoap/plugin/logging.c.