I create a complete pluggin in Wordpress using ZendFramework and now i'd like to expose a webservice to access the data because i need to create a c# importation application.
The problem i'm facing is that even though i set the type of a webservice return to a specific type, the classmap is not kicking in and transforming the type. For example:
/**
* Retursn all events registered on the sgm web interface
*
* @return models_event[]
*/
public function getAllEvents(){
return models_event::getEvents();
}
defines that the class returned in a models_event array. If i launch the WSDL section, i get a complex type added as "models_event" but heres what's wrong:
$autodiscover = new Zend_Soap_AutoDiscover(array(
'classmap' => array(
'event' => "models_event",
),
'encoding' => 'utf-8'
));
$autodiscover->setComplexTypeStrategy(new Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex());
$autodiscover->setClass('models_webservice');
$autodiscover->handle();
I class mapped models_event to event. So my WSDL should export the complex type:
<xsd:complexType name="ArrayOfmodels_event">
<xsd:complexContent>
<xsd:restriction base="soap-enc:Array">
<xsd:attribute ref="soap-enc:arrayType" wsdl:arrayType="tns:models_event[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="models_event">
<xsd:all/>
</xsd:complexType>
But as you can see it is returning a models_event[] complexe type and models_event complex type... i'm all messed up... Why is it doing this?
What version of Zend Framework are you working with?
In the version that I'm looking at (1.11.10),
Zend_Soap_AutoDiscover
does not take an array of options as one of the constructor arguments. The method signature for the constructor is as follows:The
classmap
option you are referring to is inZend_Soap_Server
and, IMO, exists mainly because Zend_Soap_Server is mostly just a wrapper around PHP's nativeSoapServer
class, so it's interface allows you to access all of the options that are provided by the underlying class. I'm also guessing that that theclassmap
option exists in order to solve a slightly different problem, which is where you are building a SOAP server based on pre-existing WSDL and would like to map WSDL names to internal PHP class names.My advice would simply be to rename the
models_event
class toevent
(or, better still,Event
), which will hopefully get you closer to what you are looking for in the WSDL.