I'm trying to call a function via a SOAP webservice. The following code is run:
$return_soap = $this->soap->__soapCall($soap_function, $params);
I have also tryed:
$return_soap = call_user_func_array(array($this->soap,$soap_function),$params);
The headers are good, and i'm sending the following parameters:
$params = array('customer_info'=>array_values( 'name'=>'Stephen de Tester',
'i_parent'=>12695,
'iso_4217'=>'EU',
'i_customer_type'=>1,
'opening_balance'=>'10.00',
'i_customer_class'=>1));
i have tryed it without array_values and a bunch of other combinations. I always get the following message:
( [error] => SOAP-ERROR: Encoding: object hasn't 'customer_info' property )
However if i try a webservice call without parameters it all seems to work perfectly...
Could you guys help me in the right direction?
Could you supply the url to the WSDL file for the service? I'm not quite sure from the error but it's either saying that you haven't supplied a customer_info property or that you've supplied a customer_info property on a method that doesn't accept that property. Either way a peek at the WSDL should help make it clearer.
Related
I have a Cest with a _before() that has the following code in it to authenticate (API testing):
// Log a user in
$I->haveHttpHeader('Accept', 'application/json');
$I->sendPOST('/authentication/login', ['username' => $this->username, 'password' => $this->password]);
$this->api_token = json_decode($I->grabResponse())->token;
When I run the test I get the following error:
[PHPUnit_Framework_Exception] Trying to get property of non-object
Scenario Steps:
3. $I->grabResponse() at tests/api/ApiBase.php:19
2. $I->sendPOST("/authentication/login",{"username":"user#examplecom","password":"abc123"}) at tests/api/ApiBase.php:17
1. $I->haveHttpHeader("Accept","application/json") at tests/api/ApiBase.php:16
tests/api/ApiBase.php:19 is $this->api_token = json_decode($I->grabResponse())->token;
It appears as if $I is no longer an object, but I have confirmed that it is still an instance of ApiTester. So the only thing I can think of is the call to the property of a non-object is somewhere deeper down.
How can I tell where? I'm running this with the --debug switch enabled.
[EDIT] This isn't a problem with the json_decode. If I move $I->grabResponse() up then the error will be on that line.
Validate response before using it.
seeResponseJsonMatchesJsonPath checks if the element is present in json response.
$I->seeResponseJsonMatchesJsonPath('$.token');
Also it could be useful to use grabDataFromResponseByJsonPath method instead of parsing it yourself.
$this->api_token = $I->grabDataFromResponseByJsonPath('$.token')[0];
[0] is necessary because grabDataFromResponseByJsonPath returns a list of matching items.
You may need to install flow/jsonpath library to get JsonPath methods working if it isn't installed yet.
I' ve a problem with Soap (I'm using it for the first time!).
I'm trying to solve a problem with SOAP, used to communicate between my site and another.
In SoapServer (on my site) I have a function called say_hello() that takes no argument and returns simply "hello", if I call it from a SoapClient, also with an argument, it works well.
The problem appears if the argument passed is "SELECT everythingyouwanthere FROM otherthingifyouwant". I don't know why but it returns "PHP Fatal error: Uncaught SoapFault exception: [HTTP] Not Found" (404 error).
This started to happen suddenly (or, at least, I don't know the causes). On the server PrestaShop is installed.
Thanks in advance!
P.S. Sorry for my bad english!
try to pass the argument through an array.
Instead of
...
$client = new SoapClient(WSDL);
$client->say_hello("SELECT everythingyouwanthere FROM otherthingifyouwant");
...
try
...
$client = new SoapClient(WSDL);
$client->say_hello(array("parameter_name" => "SELECT everythingyouwanthere FROM otherthingifyouwant"));
...
I am trying to create a Soap request to query an automotive vehicle api. Whenever I run the call I get a client error of the following.
Fatal error: Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding: object hasn't 'accountInfo' property in ...
However I have defined it as a property. Relevant lines below:
DEFINE ('API_ENDPOINT',"http://services.chromedata.com/Description/7a?wsdl");
DEFINE ('API_SECRET',"xxx");
DEFINE ('API_ACCTNO',"123456");
DEFINE ('DEBUG',"1");
$useridentification = array('accountInfo' =>array('_'=>"",'number'=>API_ACCTNO, 'secret'=>API_SECRET, 'country'=>'US', 'language'=>'EN', 'behalfof'=>'?'));
enter code here
$vinobject = array('vin'=>$vin);
$buildrequest=array($useridentification, $vinobject);
$client = new SoapClient(API_ENDPOINT);
$response = $client->describeVehicle($buildrequest);
Hopefully this is something obvious to those that work with soap APIs regularly.
Screw SoapClient, using curl. Hope it workks for you.
I'm trying to extract data from a tumblr XML-Feed and it works perfectly on my local MAMP-Server. However, having uploaded it to my provider's server I get the following error:
Fatal error: Call to a member function xpath() on a non-object in
/home/httpd/vhosts/anthronaut.net/subdomains/nico/httpdocs/scripts/tumblr.php
on line 19
Here's the part of the code in question:
$request_url = "http://nicolasblandin.tumblr.com/api/read";
$xml = simplexml_load_file($request_url);
$posts = $xml->xpath("/tumblr/posts/post");
My hunch is that the serverside settings need to be changed. I found one setting allow_url_fopenand set it to true, however with no success.
Any ideas would be greatly appreciated! Thanks
The problem seems to be that simplexml_load_file returns an array of type SimpleXMLElement. So, changing the third line of your code to
$posts = $xml[0]->xpath("/tumblr/posts/post");
seems to solve the issue. The real question is now: why does it actually work in the other case?
I am using a Zend_Soap_Client to call a web service. I am getting an exception from the error which I suspect is down to me not sending something along with the request:
Fatal error: Uncaught SoapFault exception: [Sender] SOAP-ERROR:
Encoding: object hasn't 'V24Flag' propert
Because it throws an exception I want to try view what is the actual request being sent, however because of the exception, I can not use Zend_Soap_Client->getLastRequest() to get the request (it returns null). Looking at the Zend_Soap_Client->getLastRequest() its a thin wrapper for soapClient->__soapCall() which I'm not sure how to dig deeper from.
Your problem is actually slightly different to what you think it is. The reason Zend_Soap_Client::getLastRequest() returns NULL for you is that no request was ever made: the error is being thrown at the stage where the request internally is being compared against the WSDL you are using. So the method is perfectly correct to return NULL.
As to how to form the parameter for your SOAP call so this error isn't thrown, I can't be of much greater help right now (I expect it depends partly on the services you are integrating with), but there's a userland answer on the php.net page for SoapClient::__soapCall() which may point you in a fruitful direction. Essentially, some people seem to have got somewhere by doing a deep conversion of an array structure into stdClass objects. That doesn't seem to be the whole story (it isn't for the issue I'm currently investigating), and indeed this may be down to a bug in PHP, but I hope it helps you towards an answer.
How about
try {
$client = new Zend_Soap_CLient();
$client->doSomething($params);
} catch(SoapFault $f) {
echo $f->getTraceAsString();
}
Btw. Zend_Soap_Client->getLastRequest() wraps SoapClient::__getLastRequest();