Is there a way to get a callback from the gSoap framework before a server operation is executed? I can read in the documentation that there is a callback (fserveloop) that is called immediately after a server operation is successfully completed, but not before.
The reason I need this is because the program receives requests from several sockets and one of the sockets should only allow a subset of the operations. Hence an access check needs to be performed after parsing is completed, so that we know which operation has been called, but before the operation is executed. Or maybe there is a better way of doing this?
Is there a way to get a callback from the gSoap framework before a server operation is executed?
You could use one of the other callbacks, for example the fparse callback that is called to parse the HTTP headers. You just need to make sure that afterwards you call the original fparse callback function. Like so:
soap->user = (void*)soap->fparse; // save original callback to the user variable
soap->fparse = myfparse; // set new callback
where
int myfparse(struct soap *soap)
{
// call original callback
int err = soap->user != NULL ? ((int (*)(struct soap*))soap->user)(soap) : SOAP_OK;
if (err == SOAP_OK)
{
... // your logic goes here
}
return err;
}
Note:
soap->user to a struct with data and a member for the original fparse function pointer that you will need.((int (*)(struct soap*)) is only safe if you're using it in myfparse as shown after you've made sure to set the soap->user to the original fparse function.