Code: Select all
processRequest() updating, protected;
vars
ip_address : String;
consumerValid : Boolean;
begin
ip_address := getServerVariable('REMOTE_ADDR');
consumerValid := getConsumer(ip_address);
if not consumerValid then
setError(23,"Unknown consumer","Unknown consumer");
endif;
inheritMethod();
end;
This example is only one thing I am checking for, I also have some SOAP headers that contain additional information that I need to check, and again I would like to check all the required data before calling the actual webservice method. Now I have the SOAP header working fine, but that entails overriding the processRequestPostHeaders method, which is fine, but again even if I call setError it still quite happily continues to the actual web method, seemingly oblivious to the attempt to circumvent the process.
I had some success in overriding reply(), and only calling return inheritMethod() when all my checks were successfully done, but again setError did not work, and it appeared that my only option to return a SOAP error was to manually output the required XML, which seemed like a 'really, do I have to' moment.
I was looking at the JADE WP WebServices_Security whitepaper, and although I am not intending to go full whole hogg in to WS-Security (Well, not initially at least), and they are doing a similar thing, and they are calling a raiseSecurityTokenException() method when things are missing from the header. Now it mentions this method in the document as far as to say
- although a search of the document finds no such definition elsewhere in the document?!. Although it is leading me to believe that the way to handle this is to raise an exception, but I feel that it will end up with manually writing XML out as the return error messages,Lines 15 through 25 validate that the required headers are present. If they are not, an exception is raised by calling the raiseSecurityTokenException method, which is defined elsewhere in this document.
I was wondering if anyone could assist, or point me in a better direction if I am tackling this the wrong way. Ultimately the requirement is to check some supplied parameters in the SOAP request (One being the IP address so not really supplied in the SOAP, the rest are in the SOAP header), if the supplied parameters are not valid, or missing, or not correct in the context that they are tring to be used, then the request should be rejected, with a reasonably helpful SOAP error of course, and not continue.