Как мне сделать правильный запрос, используя Zend_Soap_Client? - PullRequest
0 голосов
/ 01 декабря 2011

Я делаю запрос на мыло со следующим кодом:

$client = new Zend_Soap_Client($ws_url);

$reqFilter = array();
$reqFilter['CustomTemplateId'] = 33117; 
$reqFilter['StartDate'] = '2011-11-01T00:00:00';
$reqFilter['EndDate'] = '2011-11-01T00:00:00';

$secArr = Array();
$secArr['Key'] = '----------';
$secArr['UserName'] = 'joe';
$secArr['Password'] = '----------';

try{
  $result = $client->RequestCustomReport(array('reportDefinition'=>$reqFilter),array('securityCredentials'=>$secArr) );
}
catch(Exception $e){
  echo 'bad times';
  echo $client->getLastRequest().'<hr>';
  echo $e;
}

Создает этот фактический запрос на мыло:

<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://api.dc-storm.com/broker/engage/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <env:Body>
        <ns1:RequestCustomReport>
            <ns1:reportDefinition>
                <ns1:CustomTemplateId>33117</ns1:CustomTemplateId>
                <ns1:StartDate>2011-11-01T00:00:00</ns1:StartDate>
                <ns1:EndDate>2011-11-01T00:00:00</ns1:EndDate>
            </ns1:reportDefinition>
        <param1>
            <item>
                <key>securityCredentials</key>
                <value>
                    <item>
                        <key>Key</key>
                        <value>--------------</value>
                    </item>
                    <item>
                        <key>UserName</key>
                        <value>joe</value>
                    </item>
                    <item>
                        <key>Password</key>
                        <value>-------------</value>
                    </item>
                </value>
            </item>
        </param1>               
        </ns1:RequestCustomReport>
    </env:Body>
</env:Envelope>

Сравнивая это с тем, что должно быть запрошено:

<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://api.dc-storm.com/broker/engage/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <env:Body>
        <ns1:RequestCustomReport>
            <ns1:reportDefinition>
                <ns1:CustomTemplateId>33117</ns1:CustomTemplateId>
                <ns1:StartDate>2011-11-01T00:00:00</ns1:StartDate>
                <ns1:EndDate>2011-11-01T00:00:00</ns1:EndDate>
            </ns1:reportDefinition>
            <ns1:securityCredentials>
                <ns1:Key>--------------------</ns1:Key>
                <ns1:UserName>joe</ns1:UserName>
                <ns1:Password>--------------------</ns1:Password>
            </ns1:securityCredentials>
        </ns1:RequestCustomReport>
        </env:Body>
</env:Envelope>

Проблема в том, что узел securityCredentials отформатирован неправильно. То, что я не понимаю, это то, как факт «reportDefinition» является правильным, но почему не «securityCredentials». Я передаю параметры "securityCredentials" и "reportDefinition" тем же способом в метод "мыло" и ожидаю, что структура будет создана из анализа wsdl.

Я проверил wsdl и определение securityCredentials присутствует и связано в параметре метода так же, как reportDefinition.

Есть что-то, что я пропускаю?

1 Ответ

0 голосов
/ 02 декабря 2011

Я полагаю, что без WSDL все будут догадываться о вашей проблеме. Итак, вот мое предположение.

Попробуйте это:

$client->RequestCustomReport(array(
    'reportDefinition'    => $reqFilter, 
    'securityCredentials' => $secArr
));
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...