yii2-services
yii2-services copied to clipboard
Return complex type
Hello, I'm trying return complex type from action:
public function actions()
{
return [
'soap' => [
'class' => WebServiceAction::class,
'wsdlUrl' => 'http://smsbat.local/service/soap',
'serviceUrl' => 'http://smsbat.local/service/soap?ws=1',
'classMap' => ['TestMessage' => \app\controllers\TestMessage::class]
],
];
}
/**
* @param string msid
* @return \app\controllers\TestMessage
* @soap
*/
public function SendMessage($msid)
{
$obj = new TestMessage();
$obj->messageID = 123;
$obj->msid = 12312321;
return $obj;
}
..............
namespace app\controllers;
class TestMessage{
public $msid;
public $name = 'test';
}
But in response I see:
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:app/controllers/ServiceControllerwsdl" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:SendMessageResponse>
<return xsi:type="ns1:TestMessage"/>
</ns1:SendMessageResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
where no properties of TestMessage object :( Am I doing something wrong or misunderstanding how this is supposed to work? Please help me.
Hell, @hartois! Check WSDL description of TestMessage, it should contains properties msid,name. It looks like you forgot to add annotations to these properties.
class TestMessage{
/**
* @soap
*/
public $msid;
...
}
I'm added:
class TestMessage{
/**
* @soap
*/
public $msid;
/**
* @soap
*/
public $name = 'test';
}
but in wsdl:
<xsd:complexType name="TestMessage">
<xsd:all/>
</xsd:complexType>
cache disabled by:
ini_set("soap.wsdl_cache_enabled", '0');