2010-03-22 43 views
2

這是我的代碼:?爲什麼我不能通過這個php發送SOAP請求到Ebay查找API?

<?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); 

>

這是我收到的錯誤:

Fatal error: Uncaught SoapFault exception: [axis2ns2:Server] Missing SOA operation name header in C:\xampplite\htdocs\OOP\newfile.php:25 Stack trace: #0 C:\xampplite\htdocs\OOP\newfile.php(25): SoapClient->__soapCall('findItemsByKeyw...', Array) #1 {main} thrown in C:\xampplite\htdocs\OOP\newfile.php on line 25

它沒有任何意義,我已經在頭設置的操作名稱的請求... 有誰知道這裏有什麼問題嗎?

回答

0

將代碼放在try/catch和var_dump()中,這是你得到的異常。這應該給你更詳細的問題是什麼。

+0

它沒有提供任何其他有用的信息,只是:「缺少SOA操作名稱標題」,即使我設置了操作名稱標題。 太令人沮喪了 – Jay 2010-03-22 22:38:12

1

根據SoapHeader documentation,您需要傳遞一個名稱空間(或至少爲NULL)作爲頭構造調用的第一個參數。

0

我知道這是真的老 - 但你需要指定下面的HTTP頭(不是肥皂頭 - 請注意區別)。

這裏是尋找服務工作的例子:

內容類型:SOAP12 X-EBAY-SOA-OPERATION-NAME:findItemsByKeywords X-EBAY-SOA-SECURITY-APPNAME:您-ebay-應用程序ID

相關問題