PHP SOAP Fatal Error - php

I'm trying to integrate cargo system to my website. Then I'm using their webservice.
But I've an error like that:
"Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't find in "
And error show me that line: 2 second. And that line has that code:
$client = new SoapClient("http://customerservices.araskargo.com.tr/ArasCargoCustomerIntegrationService/ArasCargoIntegrationService.svc");
And here's my full code:
<?php
$client = new SoapClient("http://customerservices.araskargo.com.tr/ArasCargoCustomerIntegrationService/ArasCargoIntegrationService.svc");
$queryInfo = "<QueryInfo>".
"<QueryType>2</QueryType>".
"<Date>07.10.2015</Date>".
"</QueryInfo>";
$loginInfo = "<LoginInfo>".
"<UserName>xxx</UserName>".
"<Password>xxx</Password>".
"<CustomerCode>xxx</CustomerCode>".
"</LoginInfo>";
$result = $client->GetQueryXML(array('loginInfo'=>$loginInfo,'queryInfo'=>$queryInfo));
echo $result;
How can I solve my problem?

The url you're passing to SoapClient is not that of a wsdl file. You maybe meant to use:
$client = new SoapClient("http://customerservices.araskargo.com.tr/ArasCargoCustomerIntegrationService/ArasCargoIntegrationService.svc?singleWsdl");

Related

SOAP Request from PHP is not working

I have a web service available # http://www.xxxxx/zzzzzzzz/service.asmx and I am trying to send a SOAP request for method - some_function with both the parameters but still not able to get the connection through.
This is my code:
<?php
$param = array('cedula'=>'XXXX','contrasena'=>'YYYYYY');
$client = new SoapClient("http://www.xxxxx/zzzzzzzz/service.asmx?wsdl");
$result = $client->__soapCall('some_function', $param);
print $result;
?>
Error that I'm getting is:
Fatal error: Uncaught SoapFault exception: [soap:Server] Server was unable to process request. ---> Object reference not set to an instance of an object. in /home/zzzz/XXXXXXXXXX.com/uni/index.php:6 Stack trace: #0 /home/zzzz/XXXXXXXXXX.com/uni/index.php(6): SoapClient->__soapCall('some_function' , Array) #1 {main} thrown in /home/zzzz/XXXXXXXXXX.com/uni/index.php on line 6
Please suggest the corrections. Many thanks in advance :)
Thanks #dootzky & #lulco. I have solved this. Code below works perfectly fine for me:
<?php
ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$wsdl_path = "http://www.xxxxxxx/zzzzzzzzzz/service.asmx?WSDL";
$login_id = 'XXXX';
$password = 'YYYYYY';
$client = new SoapClient($wsdl_path, array('trace' => 1));
try {
echo "<pre>\n";
$result = $client->SOME_FUNCTION(array("request" => array("cedula" => $login_id, "contrasena" => $password)))
print_r($result);
echo "\n";
}
catch (SoapFault $exception) {
echo $exception;
}
?>
I think you are very close to getting this code to work. I would also give credit to this answer on StackOverflow, looks very similar to what you are asking:
"Object reference not set to an instance of an object" error connecting to SOAP server from PHP
So maybe you should just shoot the method directly, like so:
$client->SOME_FUNCTION(array("request" => array('cedula'=>'XXXX','contrasena'=>'YYYYYY'));
Hope that helps! :)
I think it could be problem in wsdl for service SOME_FUNCTION.
Here is the list of services:
http://www.xxxxxx/zzzzzzzzzz/service.asmx
All of them work, but SOME_FUNCTION doesn't. Go to url http://www.xxxxxx/zzzzzzzzzz/service.asmx?op=SOME_FUNCTION and try to set parameters and click Invoke. It will not work and throw exception "Object reference not set to an instance of an object.".
Then try another service, it will work and return some result.
Example for OTHER_FUNCTION service works:
$param = array('estatus'=>'XXXX');
$client = new SoapClient("http://www.xxxxxx/zzzzzzzzzz/service.asmx?wsdl");
$result = $client->__soapCall('OTHER_FUNCTION', $param);
print_r($result);

SOAP-ERROR: Encoding: object has no 'sortAscending' property"

Here is the code that makes the SOAP call
require_once("zulutradeClient.php");
date_default_timezone_set('America/New_York');
$params->providerId = 128391;
$params->validTrades = true;
$params->lotSize = "Standard";
$params->start = 0;
$params->length = 20;
//$params->sortAscending = false;
$params->fromDateStr = "1986-08-27T09:00:00";
$params->toDateStr = "2014-01-12T09:00:00";
$params->sortBy = "dc";
$ztclient = new zulutradeClient();
$response = "";
try {
$response = $ztclient->GetProviderTrades( $params );
var_dump($response);
}
catch (SoapFault $e) {
var_dump($e);
}
The wsdl is here
http://www.zulutrade.com/WebServices/Performance.asmx?WSDL
When the 'sortAscending' is commented out, i get the no property error:
SOAP-ERROR: Encoding: object has no 'sortAscending' property"
When it is uncommented I get the following error:
message: Could not connect to host
faultcode: http
It seems really hopeless, I've tried everything, and it just doesn't want to take that parameter.
When the 'sortAscending' is commented out, i get the no property error:
SOAP-ERROR: Encoding: object has no 'sortAscending' property"
<s:element minOccurs="1" maxOccurs="1" name="sortAscending" type="s:boolean" />
sortAscending is a mandatory field in wsdl, that's why you are getting above error.
When it is uncommented I get the following error:
message: Could not connect to host
faultcode: http
There is no fault in your request soap message here. The issue here is, this end point url.
http://www.zulutrade.com:81/WebServices/Performance.asmx
It is not accessible. Connect with your wsdl provider regarding this. you can not do anything about that.
Most probably, this srvice would be hosted on some other port rather than 81.

Is it possible to extract RDFa from html page using EasyRdf?

I'm trying to extract RDFa data from an html page using EasyRDF. But it doesn't seem to work. E.g., I've tried:
$work = new EasyRdf_Graph("http://example.com/");
$work->load();
echo $work;
$title = $work->primaryTopic();
echo "Title: ".$title->get('dc:title')."\n";
This is the error I get:
Fatal error: Uncaught exception 'InvalidArgumentException' with message 'EasyRdf_Http_Client only supports the 'http' and 'https' schemes.'

Uncaught SoapFault

I am getting the following error when trying to create a new SoapClient.
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://api.mindbodyonline.com/0_5/ClassService.asmx?wsdl' : failed to load external entity "https://api.mindbodyonline.com/0_5/ClassService.asmx?wsdl" in C:\xampp\htdocs\Work\Ice\default\soaptest.php:8 Stack trace: #0 C:\xampp\htdocs\Work\Ice\default\soaptest.php(8): SoapClient->SoapClient('https://api.min...') #1 {main} thrown in C:\xampp\htdocs\Work\Ice\default\soaptest.php on line 8
what would cause the WSDL to not load?
Enable openssl in your php.ini you load the WSDL over https this is only working when the openssl module is enabled.
Not sure if this might be the case with you but if you are using the PHP classes provided on the Minbody API on Github, note that they have recently updated them. I had the same problem with classService.php. If you are using classService.php, update the constructor function to the following (same will apply to other services):
function __construct($debug = false)
{
$endpointUrl = "https://" . GetApiHostname() . "/0_5/ClassService.asmx";
$wsdlUrl = $endpointUrl . "?wsdl";
$this->debug = $debug;
$option = array();
if ($debug)
{
$option = array('trace'=>1);
}
$this->client = new soapclient($wsdlUrl, $option);
$this->client->__setLocation($endpointUrl);
}

How to fix error returned by __soapCall?

$param['websiteConfigID'] = 729872;
$param['numberOfRecords'] = 10;
$param['numberOfRecords'] = 10;
$client = new SoapClient(WSDL);
$result = $client->__soapCall('GetTicketsStringInputs', array('parameters' => $param));
$result holding this error message....
Fatal error: Uncaught SoapFault exception:
[Client] Function ("GetTicketsStringInputs") is not a valid method for this service in /home/fmticket/public_html/inc/genericLib.php:279
Stack trace:
#0 /home/fmticket/public_html/inc/genericLib.php(279): SoapClient->__soapCall('GetTicketsStrin...', Array)
#1 /home/fmticket/public_html/resultsTicket.php(12): getTickets(Array)
#2 {main} thrown in /home/fmticket/public_html/inc/genericLib.php on line 279
how to resolve it?? plz help.
Your code is calling the remote GetTicketsStringInputs function :
$client->__soapCall('GetTicketsStringInputs', ...
The Fatal error you get indicates :
Function ("GetTicketsStringInputs") is not a valid method for this service
It seems pretty clear : the method you're trying to call doesn't exist, it is not provided by the remote web-service.
So, to fix that Fatal Error, you have to stop calling that function ;-)
You should check the WSDL of your webservice : does it really export such a method ?

Categories