PHP SoapClient - Returning attribute values in a response

╄→尐↘猪︶ㄣ 提交于 2019-12-01 11:25:41

I find that I have to supply a "classmap" to SoapClient to get it to map the objects in the response to classes that are defined in PHP. In WSDLs the type name is usually lower camel case (starting with lower case and camel case the rest).

class MY_Campaign {
    private $name;
    function getName () { return $this->name; }
}

$options = array(
        'classmap' => array(
                'campaign' => 'MY_Campaign',
            );
    );
$client = new SoapClient('http://example.com/yourservice?wsdl', $options);
$return = $client->GetCampaigns ();

I might be able to supply a better answer if I had the WSDL. The classmap depends on the type definitions in the WSDL file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!