Neden bu php ile API bulma Ebay soap istekleri göndermek değil mi?

4 Cevap php

Bu benim kodudur:

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

>

Ve bu aldığınız hata:

Ölümcül hata: yakalanmamış SoapFault istisna: [axis2ns2: Server] C Eksik SOA operasyon isim başlığı: \ xampplite \ htdocs \ cepten \ newfile.php: 25 Stack trace: # 0 C: \ xampplite \ htdocs \ OOP \ newfile.php ( 25): SoapClient-> __soapCall ('findItemsByKeyw ...', Array) # 1 {main} C atılmış: \ xampplite \ htdocs \ cepten \ newfile.php on line 25

It doesnt make sense, I have already set the operation name in the header of the request... Does anyone know what is wrong here?

4 Cevap

Göre SoapHeader documentation, sen başlığı inşaat aramanın ilk parametre olarak bir ad (ya da en azından NULL) geçmesi gerekiyor.

Bir try / catch ve var_dump () alıyoruz istisna kodu yerleştirin. Yani sorun ne kadar daha fazla ayrıntı vermek gerekir.

Henrik olduğuna işaret için teşekkürler, ben kod güncellenen, ancak ben yine aynı hatayı alırsınız: "SOA işlem adı başlığını Eksik"

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("http://www.ebay.com/marketplace/search/v1/services","X-EBAY-SOA-MESSAGE-PROTOCOL:", "SOAP12");
$header_arr[] = new SoapHeader("http://www.ebay.com/marketplace/search/v1/services","X-EBAY-SOA-SERVICE-NAME:", "FindingService");
$header_arr[] = new SoapHeader("http://www.ebay.com/marketplace/search/v1/services","X-EBAY-SOA-OPERATION-NAME:", "findItemsByKeywords");
$header_arr[] = new SoapHeader("http://www.ebay.com/marketplace/search/v1/services","X-EBAY-SOA-SERVICE-VERSION:", "1.0.0");
$header_arr[] = new SoapHeader("http://www.ebay.com/marketplace/search/v1/services","X-EBAY-SOA-GLOBAL-ID:", "EBAY-GB");
$header_arr[] = new SoapHeader("http://www.ebay.com/marketplace/search/v1/services","X-EBAY-SOA-SECURITY-APPNAME:", ""); 
$header_arr[] = new SoapHeader("http://www.ebay.com/marketplace/search/v1/services","X-EBAY-SOA-REQUEST-DATA-FORMAT:", "XML");
$header_arr[] = new SoapHeader("http://www.ebay.com/marketplace/search/v1/services","X-EBAY-SOA-MESSAGE-PROTOCOL:", "XML");

$client->__setSoapHeaders($header_arr); 

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

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

try{
    $result = $client->__soapCall("findItemsByKeywords", $FindItemsByKeywordsRequest);
}
catch (Exception $e) {
    var_dump($e);
}

Ben bu gerçekten eski olduğunu biliyorum - ama şu HTTP başlıklarını (değil sabun başlıkları - ayrımın farkında olmak) belirtmeniz gerekir.

İşte hizmet bulmak için çalışan bir örnek:

CONTENT-TYPE: SOAP12 X-EBAY-SOA-OPERATION-NAME: findItemsByKeywords X-EBAY-SOA-SECURITY-APPNAME: YOUR-ebay-app-id