View RSS Feed

Development Team Blog

A procedure that does not return a value, does not return a value

Rate this Entry
Most procedures do not return a value, so don't be surprised when you get no return value from a web service method that's a procedure. This may sound obvious, but it can be confusing when you get an unexpected message that seems to suggest something's wrong.

A bug report actually made it all the way to our bugtracker system, actually suggesting we should disable use of Procedure for web service methods. This suggestion was based on a logical but mistaken conclusion formed by an error message in the browser, stating that the returned data contains no element. It seemed like this was wrong, and it was best to remove the ability to create web service procedures, to avoid the browser error when trying to display the empty result from the test page for the procedure that didn't return anything. Luckily of course, it's a feature we're not planning to implement (or remove as the case would be).

Well formed XML must contain exactly one top level element. But because the web service method was a procedure, it didn't actually return anything, so there was no top level element. When the browser tries to display an empty XML document, it will typically display an error message. But of course, that's exactly as it should be, as the web service method returned no data because it's a procedure.

Note that this empty XML document problem only applies to the web service test page. If you use SOAP to access the web service method, rather than the test page, the response will contain a SOAP envelope and body. So the return value is still empty, but the response contains the SOAP wrapper, thus it's not an empty XML document. The test page just returns the return value (which is void), without the SOAP envelope wrapper, hence it's an empty XML document.

Now of course, it would be better if the browser didn't display such an error when the web service method returns no data. The web service test page has been improved in the next version of Visual DataFlex, by changing the response content type to text/html as a workaround for web service methods with no return type.

Comments

  1. Knut Sparhell's Avatar
    You could return an empty element
    Code:
    <procedure_name/>
    because you should avoid triggering an error when there is no error, even if if an error is "logical" in your view.
    Updated 22-Jan-2010 at 11:53 PM by Knut Sparhell