English 中文(简体)
Why can t I send SOAP requests to Ebay finding API?
原标题:

This is my code:

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

And this is the error I receive:

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

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

问题回答

According to the SoapHeader documentation, you need to pass a namespace (or at least NULL) as the first parameter of the header construction call.

Place the code in a try/catch and var_dump() the exception you re getting. That should give you more detail as to what is the problem.

I know this is REALLY old - but you need to specify the following HTTP headers (not soap headers - be aware of the distinction).

Here is an example that works for finding service:

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





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签