ZF-10754: Missing attribute name in fault type declaration in generated WSDL

Description

When we try to set a new fault return type in wsdl listed method with Zend_Soap_Wsdl, it failed to add name attribute.

When trying to use addPortOperation with fault argument, it doesn't add the name attribute. SoapUI failed to load wsdl without name attribute here.

Possible fix:


if (is_string($fault) && (strlen(trim($fault)) >= 1)) {
            $node = $this->_dom->createElement('fault');
            $node->setAttribute('message', $fault);
            //remove tns:
            $node->setAttribute('name', substr(strchr($fault, ':'), 1)); 
            $operation->appendChild($node);
        }

Existing code:


if (is_string($fault) && (strlen(trim($fault)) >= 1)) {
            $node = $this->_dom->createElement('fault');
            $node->setAttribute('message', $fault); 
            $operation->appendChild($node);
        }

Comments

Warning patch including fix for ZF-10755 !

Warning test suite file patch include test for ZF-10755

Patches look good, please provide screenshot of failed validation in soap ui. Ill then commit it.

For this one, it's a little more complicate to show effect. In fact, it is not exactly a WSDL standard problem. SOAP UI can load the WSDL without mistake. However, the SoapServer extension of PHP is making trouble here. If it does not find the name attribute, it will return empty answer at any request to the webservice. So in fact, SoapServer extension could be changed to be less strict and not ask for the missing name attribute to do the job, or we can patch Zend Framework to handle SoapServer behavior of PHP. I recommend patch Zend Framework...

Here a log of SOAP UI before and after the fix :


Before (empty answer):
Fri May 06 11:07:57 CEST 2011:DEBUG:>> "POST /index/soapserver HTTP/1.1[\r][\n]"
Fri May 06 11:07:57 CEST 2011:DEBUG:>> "Accept-Encoding: gzip,deflate[\r][\n]"
Fri May 06 11:07:57 CEST 2011:DEBUG:>> "Content-Type: text/xml;charset=UTF-8[\r][\n]"
Fri May 06 11:07:57 CEST 2011:DEBUG:>> "SOAPAction: "http://www.aaaaaaa.fr/index/soapserver#getUserInfos"[\r][\n]"
Fri May 06 11:07:57 CEST 2011:DEBUG:>> "User-Agent: Jakarta Commons-HttpClient/3.1[\r][\n]"
Fri May 06 11:07:57 CEST 2011:DEBUG:>> "Host: www.aaaaaaa.fr[\r][\n]"
Fri May 06 11:07:57 CEST 2011:DEBUG:>> "Content-Length: 289[\r][\n]"
Fri May 06 11:07:57 CEST 2011:DEBUG:>> "[\r][\n]"
Fri May 06 11:07:57 CEST 2011:DEBUG:>> "www.aaaaaaa.fr/index/soapserver">[\r][\n]"
Fri May 06 11:07:57 CEST 2011:DEBUG:>> "   [\r][\n]"
Fri May 06 11:07:57 CEST 2011:DEBUG:>> "   [\r][\n]"
Fri May 06 11:07:57 CEST 2011:DEBUG:>> "      [\r][\n]"
Fri May 06 11:07:57 CEST 2011:DEBUG:>> "         [\r][\n]"
Fri May 06 11:07:57 CEST 2011:DEBUG:>> "      [\r][\n]"
Fri May 06 11:07:57 CEST 2011:DEBUG:>> "   [\r][\n]"
Fri May 06 11:07:57 CEST 2011:DEBUG:>> ""
Fri May 06 11:07:57 CEST 2011:DEBUG:<< "HTTP/1.1 200 OK[\r][\n]"
Fri May 06 11:07:57 CEST 2011:DEBUG:<< "HTTP/1.1 200 OK[\r][\n]"
Fri May 06 11:07:57 CEST 2011:DEBUG:<< "Date: Fri, 06 May 2011 09:07:57 GMT[\r][\n]"
Fri May 06 11:07:57 CEST 2011:DEBUG:<< "Server: Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1[\r][\n]"
Fri May 06 11:07:57 CEST 2011:DEBUG:<< "X-Powered-By: PHP/5.3.1[\r][\n]"
Fri May 06 11:07:57 CEST 2011:DEBUG:<< "Content-Length: 0[\r][\n]"
Fri May 06 11:07:57 CEST 2011:DEBUG:<< "Content-Type: text/html[\r][\n]"
Fri May 06 11:07:57 CEST 2011:DEBUG:<< "[\r][\n]"



After (we can see the soapfault in the answer, which is what I expected with that request):
Fri May 06 11:02:34 CEST 2011:DEBUG:<< "<?xml version="1.0" encoding="UTF-8"?>[\n]"
Fri May 06 11:02:34 CEST 2011:DEBUG:<< "www.aaaaaaa.fr/index/soapserver">EtienneDupont333Jean1100Jack2200Martin3300[\n]"
Fri May 06 11:02:40 CEST 2011:DEBUG:>> "POST /index/soapserver HTTP/1.1[\r][\n]"
Fri May 06 11:02:40 CEST 2011:DEBUG:>> "Accept-Encoding: gzip,deflate[\r][\n]"
Fri May 06 11:02:40 CEST 2011:DEBUG:>> "Content-Type: text/xml;charset=UTF-8[\r][\n]"
Fri May 06 11:02:40 CEST 2011:DEBUG:>> "SOAPAction: "http://www.aaaaaaa.fr/index/soapserver#getUserInfos"[\r][\n]"
Fri May 06 11:02:40 CEST 2011:DEBUG:>> "User-Agent: Jakarta Commons-HttpClient/3.1[\r][\n]"
Fri May 06 11:02:40 CEST 2011:DEBUG:>> "Host: www.aaaaaaa.fr[\r][\n]"
Fri May 06 11:02:40 CEST 2011:DEBUG:>> "Content-Length: 289[\r][\n]"
Fri May 06 11:02:40 CEST 2011:DEBUG:>> "[\r][\n]"
Fri May 06 11:02:40 CEST 2011:DEBUG:>> "www.aaaaaaa.fr/index/soapserver">[\r][\n]"
Fri May 06 11:02:40 CEST 2011:DEBUG:>> "   [\r][\n]"
Fri May 06 11:02:40 CEST 2011:DEBUG:>> "   [\r][\n]"
Fri May 06 11:02:40 CEST 2011:DEBUG:>> "      [\r][\n]"
Fri May 06 11:02:40 CEST 2011:DEBUG:>> "         [\r][\n]"
Fri May 06 11:02:40 CEST 2011:DEBUG:>> "      [\r][\n]"
Fri May 06 11:02:40 CEST 2011:DEBUG:>> "   [\r][\n]"
Fri May 06 11:02:40 CEST 2011:DEBUG:>> ""
Fri May 06 11:02:40 CEST 2011:DEBUG:<< "HTTP/1.1 500 Internal Service Error[\r][\n]"
Fri May 06 11:02:40 CEST 2011:DEBUG:<< "HTTP/1.1 500 Internal Service Error[\r][\n]"
Fri May 06 11:02:40 CEST 2011:DEBUG:<< "Date: Fri, 06 May 2011 09:02:40 GMT[\r][\n]"
Fri May 06 11:02:40 CEST 2011:DEBUG:<< "Server: Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1[\r][\n]"
Fri May 06 11:02:40 CEST 2011:DEBUG:<< "X-Powered-By: PHP/5.3.1[\r][\n]"
Fri May 06 11:02:40 CEST 2011:DEBUG:<< "Content-Length: 486[\r][\n]"
Fri May 06 11:02:40 CEST 2011:DEBUG:<< "Connection: close[\r][\n]"
Fri May 06 11:02:40 CEST 2011:DEBUG:<< "Content-Type: text/xml; charset=utf-8[\r][\n]"
Fri May 06 11:02:40 CEST 2011:DEBUG:<< "[\r][\n]"
Fri May 06 11:02:40 CEST 2011:DEBUG:<< "<?xml version="1.0" encoding="UTF-8"?>[\n]"
Fri May 06 11:02:40 CEST 2011:DEBUG:<< "www.aaaaaaa.fr/index/soapserver">SOAP-ENV:ClientwsGetUserInfos: Fatal error1Parameter name missing ![\n]"