如何发送这个肥皂请求?

时间:2012-07-05 11:54:53

标签: php soap

我有肥皂请求参数:

<soap:Body>
<GetProductList xmlns="http://schemas.acme.eu/">
<GetProductListRequest>
<Filters>
<Filter>
<Name>Language</Name>
<Value>lt-lt</Value>
</Filter>
<Filter>
<Name>Currency</Name>
<Value>LTL</Value>
</Filter>
</Filters>
</GetProductListRequest>
</GetProductList>
</soap:Body>

我尝试发送这样的请求:

    $result = $client->GetProductList(array('Filters' => array(
                    'Filter'=> array('Name' => 'Language', 'Value' => 'lt-lt'), 
                    'Filter'=> array('Name' => 'Currency', 'Value' => 'LTL'))));

但我在这里得到错误:

( ! ) Fatal error: Uncaught SoapFault exception: [soap:Server] Server was unable to process request. ---> Object reference not set to an instance of an object. in C:\wamp\www\tarpine_xml\class\acme_xml.php:25 Stack trace: #0 C:\wamp\www\tarpine_xml\class\acme_xml.php(25): SoapClient->__call('GetProductList', Array) #1 C:\wamp\www\tarpine_xml\class\acme_xml.php(25): SoapClient->GetProductList(Array) #2 C:\wamp\www\tarpine_xml\index.php(18): ACME_XML->parseACME() #3 {main} thrown in C:\wamp\www\tarpine_xml\class\acme_xml.php on line 25

没有参数的其他请求工作正常..那么我的请求中哪里出错?

解决

我已创建此代码:

    $parrams['GetProductListRequest']['Filters']['Filter']  = array();
    $parrams['GetProductListRequest']['Filters']['Filter'][] = array('Name' => 'Language', 'Value' => 'lt-lt');
    $parrams['GetProductListRequest']['Filters']['Filter'][] = array('Name' => 'Currency', 'Value' => 'LTL');
    $result = $client->GetProductList($parrams);

它完美无缺:)

2 个答案:

答案 0 :(得分:1)

不熟悉此FW,但我认为您还需要在请求中添加GetProductListRequest(这是根xml标记)。

所以你应该有类似的东西:

$result = $client->GetProductList(array('GetProductListRequest'=>array('Filters' => array(
                    'Filter'=> array('Name' => 'Language', 'Value' => 'lt-lt'), 
                    'Filter'=> array('Name' => 'Currency', 'Value' => 'LTL')))));

答案 1 :(得分:0)

小修理

$params['GetProductList']['GetProductListRequest']['Filters']['Filter']  = array();
$params['GetProductList']['GetProductListRequest']['Filters']['Filter'][] = array('Name' => 'Language', 'Value' => 'lt-lt');
$params['GetProductList']['GetProductListRequest']['Filters']['Filter'][] = array('Name' => 'Currency', 'Value' => 'LTL');