Issues

ZF-6964: Zend_Soap_AutoDiscover: Allow webservices to return void

Description

When using AutoDiscover, it is currently not possible to have a method returning nothing (=void). When the portType is created, it references a message not included in the WSDL. f.e. the attached dummy-webservice creates a porttype:


from this code:


class TestService {
    /**
     * @param string $data
     * @return void
     */
    public function update($data)
    {
        // do something with $data
        // $operation_failed = true;
        if($operation_failed) {
            throw new SoapFault('Server', 'that did not work!');
        }
    }
}

without including tns:updateResponse

the fix is easy, AutoDiscover simply has to include an empty message, see patch

Comments

Testservice and client to reproduce Patch to fix AutoDiscover.php

This should already be fixed in ZF-6689, which was released with 1.8.3

really, was it? ;-)

However I tried svn trunk, which shows a different problem: Because return-void-functions are mapped to one-way-functions, the client does not wait for the soap-server (which is expected), which means it never gets the exception. (Unless called with feature SOAP_WAIT_ONE_WAY_CALLS of course) Ie. one-way-functions are functions that return no information to the caller, however in my use-case the function does return a bit of information: the presense or absense of an exception (SoapFault). (In the past I circumvented this with "@return boolean unused", but that is not clean code ;-) )

I have patched AutoDiscover.php further to check for a "@throws" in the functions/methods doc-block and only handle functions without this tag as one-way-functions. (I have however only tested this with php as client (and the eclipse-ws-explorer, which however waits for one-way-calls)) The patch simply sets isOneWayMessage back to false, the rest of the code does "the right thing" (IMHO) already, ie pass an empty array to addMessage.

This issue isn't fixed because of not generating one-way-operation "style" port bindings.

The port operation is created either one-way or two-way, but the binding is always created two-way. In ZF1.9.2/Zend/Soap/AutoDiscover.php:417 the binding operation mustn't have the output parameter for one-way operations.

re-opened because of said problems.

Bulk change of all issues last updated before 1st January 2010 as "Won't Fix".

Feel free to re-open and provide a patch if you want to fix this issue.