在我的Symfony2项目中,我需要对WebService进行SOAP调用,所以我使用composer安装了besimple/soap-client,并进行了如下配置:
parameters.yml:
soap_options: wsdl: wsdl/test.wsdl
在services.xml中
<!-- Soap Client -->
<service id="project.test.soap.wrapper"
class="Project\Test\Soap\SoapClientWrapper">
<argument key="soap_options">%soap_options%</argument>
</service>然后,我将这个服务注入到我的Dto/TestTemplate.php文件中
接下来,我在besimple/soap-client创建的Soap目录中创建了一个存储库目录,并在该存储库中添加了TestAttrebiutes.php文件:
namespace Project\Test\Soap\Repositories;
class TestAttributes {
public $agentID;
public $sourceChannel;
public $organisationName;
public function __construct(
$agentID,
$sourceChannel,
$organisationName,
){
$this->$agentID = $agentID;
$this->$sourceChannel = $sourceChannel;
$this->$organisationName = $organisationName;
}
} 所以现在在我的TestTemplate.php中,我希望做这样的事情:
$this->soap->__call(new FttpStatusAttributes(
'100',
'Web',
'Ferrari'
), **ASKING FOR ATTRIBUTES);但它要求我在添加属性后立即添加它们,我做错了什么?有可能按照我尝试的方式来做吗?
发布于 2015-11-10 05:41:42
以下代码可能是问题所在:
$this->$agentID = $agentID;
$this->$sourceChannel = $sourceChannel;
$this->$organisationName = $organisationName;当您访问$this->$agentID时,您访问的是$this的一个值为$agentID的成员。比方说,如果$agentID是john123,你的代码实际上意味着
$this->john123 = 'john123';这显然不是你想要的。您的代码应为:
$this->agentID = $agentID;
$this->sourceChannel = $sourceChannel;
$this->organisationName = $organisationName;老实说,我不知道这是否解决了问题,因为你的问题有点模糊,但这肯定是你想要解决的问题。
https://stackoverflow.com/questions/33613471
复制相似问题