PHP - SOAP调用返回错误“缺少参数”

时间:2015-12-01 12:25:11

标签: php web-services soap wsdl

我试图进行以下SOAP调用几天 - 但没有成功。我总是收到错误消息“错误:缺少参数'culture_id'”。我已经尝试了SOAP参数的几个实现。

我的代码

// Authentication - success
$authentication = array(
    'login' => 'XXX',
    'password' => 'XXX',
    'trace' => 1
);
$client = new SoapClient('http://api.autoscout24.com/AS24_WS_Lookup?wsdl', $auth);

// First try - error
$arguments = array(
    'GetLookupDataRequest' => array(
        'culture_id' => 'de-DE',
        'profile_id' => 'XXX',
        'revision' => '6'
    )
);

// Second try - error
$arguments = array(
    'culture_id'=>'de-DE',
    'profile_id'=>'XXX',
    'revision'=>'6'
);

// Third try
class GetLookupDataRequest {
    function GetLookupDataRequest($culture_id, $profile_id) {
        $this->culture_id = $culture_id;
        $this->profile_id = $profile_id;
        $this->revision = 6;
    }
}
$arguments = array(new GetLookupDataRequest('de-DE', 'XXX'));

// SOAP call
try {
    $results = $client->GetLookupData($arguments);
    //$results = $client->__soapCall('getLookupData', $arguments); -> also returns an error
    var_dump($results);
}
catch(SoapFault $fault){
    var_dump($client->__getLastRequest());
    var_dump($fault->getMessage());
}

我希望有人能帮助我。我慢慢地绝望地对这些容易的查询感到绝望。

1 个答案:

答案 0 :(得分:0)

此外,我不得不说,SOAP主体似乎是空的。这是预期的XML结构:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.autoscout24.com/webapi/" xmlns:data="http://www.autoscout24.com/webapi/data/">
       <soapenv:Header/>
       <soapenv:Body>
          <web:GetLookupData>
             <!--Optional:-->
             <web:request>
                <!--Optional:-->
                <data:client_id>XXX</data:client_id>
                <!--Optional:-->
                <data:culture_id>de-DE</data:culture_id>
                <!--Optional:-->
                <!--<data:profile_id>?</data:profile_id>-->
                <!--Optional:-->
                <data:revision>6</data:revision>
                <!--Optional:-->
                <!--<data:vehicle_type_id>?</data:vehicle_type_id>-->
             </web:request>
          </web:GetLookupData>
       </soapenv:Body>
    </soapenv:Envelope>