ZF-5604: Invalid complex type handling in strategy ArrayOfTypeComplex
Description
This is similar issue like this http://framework.zend.com/issues/browse/ZF-5430 but with ArrayOfTypeComplex strategy.
This files:
require_once 'Zend/Loader.php';
require_once './My_Service.class.php';
Zend_Loader::registerAutoload();
$autodiscover = new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex');
$autodiscover->setClass('My_Service');
$autodiscover->handle();
<?php
class My_Service
{
/**
* @param string $foo
* @return My_Response[]
*/
public function foo($foo)
{
// code
}
/**
* @param string $bar
* @return My_Response[]
*/
public function bar($bar)
{
// code
}
/**
* @param string $baz
* @return My_Response[]
*/
public function baz($baz)
{
// code
}
}
class My_Response
{
/**
* @var string
*/
public $p1;
}
generates this invalid wsdl:
<?xml version="1.0"?>
www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="My_Service" targetNamespace="http://example.com/service.php">
and it should generate wsdl like this:
<?xml version="1.0"?>
www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="My_Service" targetNamespace="http://example.com/service.php">
h3.Summary: Type of response message should be "ArrayOfMy_Response" not "My_Response[]"
Valid:
Invalid:
Solution proposed by Christian Münch in http://framework.zend.com/issues/browse/ZF-5430
91: $this->getContext()->addType($type);
changed to:
91: $this->getContext()->addType($complexTypeName);
solves this issue but duplicates complex type definition in wsdl file. For example:
My temporary solution:
472: public function toXML()
473: {
474: return preg_replace('/(?<=\s)type\=\"tns\:([a-zA-Z_]+)\[\]/', 'type="tns:ArrayOf\1', $this->_dom->saveXML());
475: // return $this->_dom->saveXML();
476: }
Comments
Posted by Benjamin Eberlei (beberlei) on 2009-01-22T12:54:38.000+0000
Fixed in trunk, will be in next minor version 1.8 - Can you please test the functionality?
Posted by Tomasz Gunerski (tommygun) on 2009-01-23T12:51:12.000+0000
Works fine now, thanks.