2

I'm using the gSoap library for my Qt C++ application to interact with some basic web service.

Is there a way to extract the full SOAP request/(response) message that is about to be sent/(was received) from soap object as XML string? (for educational purposes)

I know that there is buf member but data there would require some filtering and it looks incomplete.

Thanks in advance.

Moomin
  • 1,846
  • 5
  • 29
  • 47

3 Answers3

3

I needed to use this plugin because I wanted to log the xml messages in our logfile. This plugin shows how to redirect the fsend() and frecv() functions, which send and receive the xml message.

static int plugin_send(struct soap *soap, const char *buf, size_t len)  
{ 
  struct plugin_data *data = (struct plugin_data*)soap_lookup_plugin(soap, plugin_id);

  fwrite(buf, len, 1, stderr); //<--  pick up the xml from here!

  return data->fsend(soap, buf, len); /* pass data on to old send callback */  
}  

static size_t plugin_recv(struct soap *soap, char *buf, size_t len)  
{ 
  struct plugin_data *data = (struct plugin_data*)soap_lookup_plugin(soap, plugin_id);  
  size_t res = data->frecv(soap, buf, len); /* get data from old recv callback */ 

  fwrite(buf, res, 1, stderr); //<--  pick up the xml from here!

  return res;  
}  

There is section on plugin in the gSOAP User Guide:

https://www.cs.fsu.edu/~engelen/soapdoc2.html#tth_sEc19.38

brinkhus
  • 46
  • 1
  • 4
1

I believe that buf contains XML data from the wire, but not necessarily all of it at any one time.

If you want to do that, you'd be better off enabling debug logging inside gsoap (though you'll have to recompile it to get that to work).

Uncomment the following DEBUG statement in stdsoap.h and then recompile gsoap and your application. This will result in very handy log files produced in your application's working directory:

./stdsoap2.h:/* #define DEBUG */ /* Uncomment to debug sending (in file SENT.log) receiving (in file RECV.log) and messages (in file TEST.log) */

Vinbot
  • 518
  • 2
  • 14
0

You have to written a plugin to get access to the XML-Messages. Have a look at the pluging.h and pluging.c in the plugin directory.

brinkhus
  • 46
  • 1
  • 4