首页 文章

为什么我不能发送SOAP请求给Ebay用这个php查找API?

提问于
浏览
2

这是我的代码:

<?php
error_reporting(E_ALL);
//new instance of soapClient pointing to Ebay finding api
$client = new SoapClient("http://developer.ebay.com/webservices/finding/latest/FindingService.wsdl"); 

//attach required parameters to soap message header
$header_arr = array(); 
$header_arr[] = new SoapHeader("X-EBAY-SOA-MESSAGE-PROTOCOL", "SOAP11");
$header_arr[] = new SoapHeader("X-EBAY-SOA-SERVICE-NAME", "FindingService");
$header_arr[] = new SoapHeader("X-EBAY-SOA-OPERATION-NAME", "findItemsByKeywords");
$header_arr[] = new SoapHeader("X-EBAY-SOA-SERVICE-VERSION", "1.0.0");
$header_arr[] = new SoapHeader("X-EBAY-SOA-GLOBAL-ID", "EBAY-GB");
$header_arr[] = new SoapHeader("X-EBAY-SOA-SECURITY-APPNAME", "REMOVED"); 
$header_arr[] = new SoapHeader("X-EBAY-SOA-REQUEST-DATA-FORMAT", "XML");
$header_arr[] = new SoapHeader("X-EBAY-SOA-MESSAGE-PROTOCOL", "XML");

$test = $client->__setSoapHeaders($header_arr); 

$client->__setLocation("http://svcs.ebay.com/services/search/FindingService/v1");//endpoint

$FindItemsByKeywordsRequest  = array(
    "keywords"      =>  "potter"
);

$result = $client->__soapCall("findItemsByKeywords", $FindItemsByKeywordsRequest);

//print_r($client->__getFunctions());
//print_r($client->__getTypes());
//print_r($result);

?>

这是我收到的错误:

致命错误:未捕获的SoapFault异常:[axis2ns2:Server] C:\ xampplite \ htdocs \ OOP \ newfile.php中缺少SOA操作名称标头:25堆栈跟踪:#0 C:\ xampplite \ htdocs \ OOP \ newfile.php (25):SoapClient - > __ soapCall('findItemsByKeyw ...',Array)在第25行的C:\ xampplite \ htdocs \ OOP \ newfile.php中抛出#1

它没有意义,我已经在请求的 Headers 中设置了操作名称...有谁知道这里有什么问题?

3 回答

  • 0

    我知道这真的很旧 - 但你需要指定以下HTTP标头(不是肥皂标头 - 要注意区别) .

    以下是一个用于查找服务的示例:

    内容类型:SOAP12 X-EBAY-SOA-OPERATION-NAME:findItemsByKeywords X-EBAY-SOA-SECURITY-APPNAME:YOUR-ebay-app-id

  • 1

    将代码放在try / catch和var_dump()中,就是你得到的异常 . 这应该会给你更详细的问题 .

  • 0

    根据SoapHeader documentation,您需要传递一个名称空间(或至少为NULL)作为标头构造调用的第一个参数 .

相关问题