i m using php soapclent, other calls are working good with this URL.here is the snap of the request to be passed.
not getting what is the problem ?
( ! ) Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Client]
true in C:\wamp\www\ginger\createEditProfile.php:8 Stack trace: #0
C:\wamp\www\ginger\createEditProfile.php(8):
SoapClient->__soapCall('createEditProfi...', Array) #1 {main} thrown
in C:\wamp\www\ginger\createEditProfile.php on line 8
error_reporting(E_ALL);
$sc = new SoapClient("http://###.###.##.##/GingerIBE/services/consolidatedServicesBean.wsdl?wsdl", array('trace' => 1));
$params =array('targetProfile'=>array('loginId'=>'bhav1234','password'=>'test123','preferredHotel'=>'', 'customerId'=>'','firstName'=>'Bhavina','lastName'=>'Prajapati','customerType'=>'1','customerAccountGroup'=>'SH01','gender'=>'Female','dateOfBirth'=>'1987-11-01','emailId'=>'testing.abc#gmail.com','mobileNumber'=>'8866853905','phoneNumber'=>'8866853906','faxNumber'=>'8866853901','preferredModeOfContact'=>'','addressLine1'=>'some address line 1','addressLine2'=>'some address line 2','pinNumber'=>'','city'=>'Bangalore','state'=>'Karnataka','country'=>'India'));
$result = $sc->__soapCall('createEditProfile', array('parameters' => $params));
echo "<pre>";
print_r($result);
echo($sc->__getLastRequest());
Related
I'm learning php and started following a youtube video for a project.
When i accept contents from my json file and code it to add new contents to it, an error occurs.
Error-
Warning: Undefined variable $json_encode in /Users/montekkundan/Downloads/coding/php/newtodo.php on line 16
Fatal error: Uncaught Error: Value of type null is not callable in /Users/montekkundan/Downloads/coding/php/newtodo.php:16 Stack trace: #0 {main} thrown in /Users/montekkundan/Downloads/coding/php/newtodo.php on line 16
php code-
<?php
// echo "<pre>";
// var_dump($_POST);
// echo "</pre>";
$todoname = $_POST['todoname'] ?? "";
$todoname = trim($todoname);
if($todoname) {
$json = file_get_contents('todo.json');
$jsonArray = json_decode($json, true);
$jsonArray[$todoname] = ['completed' => false];
// echo "<pre>";
// var_dump($jsonArray);
// echo "</pre>";
file_put_contents('todo.json', $json_encode($jsonArray, JSON_PRETTY_PRINT)) ;
}
?>
Try to change
file_put_contents('todo.json', $json_encode($jsonArray, JSON_PRETTY_PRINT));
to file_put_contents('todo.json', json_encode($jsonArray, JSON_PRETTY_PRINT));
that's because you are trying to call json_encode variable, json_encode is not a variable.
I'm getting this error:
Fatal error: Uncaught SoapFault exception: [soap:Server] Server was unable to process request. ---> Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index in /var/www/index.php:30 Stack trace: #0 /var/www/index.php(30): SoapClient->__call() #1 {main} thrown in /var/www/index.php on line 30
My php-code is:
<?php
ini_set('error_log', '/var/www/php.log');
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
date_default_timezone_set('UTC');
include("include/connection.php");
$client = new SoapClient("https:// (LINK TO API) /ExternalApiWebService.asmx?wsdl", array('trace' => 1));
// **--** Login - START **--**
$LoginResult = $client->Login(
array("userName" => "USERNAME", "password" => "PASSWORD"
)
);
print "<pre>";
print_r ($LoginResult);
print "</pre>";
$SessionId = $LoginResult->LoginResult;
// **--** Login - END **--**
// **--** GetTriplogUnitPositions - START **--**
$GetTriplogUnitPositionsResult = $client->GetTriplogUnitPositions(
array("sessionId" => "".$SessionId.""
)
);
print "<pre>";
print_r ($GetTriplogUnitPositionsResult);
print "</pre>";
// **--** GetTriplogUnitPositions - END **--**
?>
Can anyone help me or give me a hint of whats wrong?
I am trying to the status of urls which are stored in a text file
in my code i have:
$filestatus = file("urlsmartins_status.txt");
foreach ($filestatus as $filestate){
$filestatusurl = (file_get_contents("$filestate"));
$filestatusurlxml = new SimpleXMLElement ($filestatusurl);
print_r ($filestatusurlxml);
}
in the urlsmartin_status.txt i have 5 urls written
http://172.27.73.5:8080/api/service/
http://172.27.73.6:8080/api/service/
http://172.27.73.7:8080/api/service/
http://172.27.73.8:8080/api/service/
But when i execute the code i have the following result
PHP Warning: file_get_contents(http://172.27.73.5:8080/api/service/
): failed to open stream: HTTP request failed! HTTP/1.1 404 OK
PHP Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in ...
Stack trace:
#0 /opt/rh/httpd24/root/var/www/html/pub/martin.php(56): SimpleXMLElement->__construct('')
#1 {main}
thrown in /opt/rh/httpd24/root/var/www/html/pub/martin.php on line 56
What am i missing here?
Thanks
the problem here is that the lines in your file are not "XML", hence SimpleXMLElement cannot be instantiated.
I get the same error like this:
I managed to fix it via
$filedata = file_get_contents('urlsmartins_status.txt');
$urls = explode("\n", trim($filedata));
foreach($urls as $key => $url) {
$filestatusurl = file_get_contents("$url");
$filestatusurlxml = new SimpleXMLElement ($filestatusurl);
print_r ($filestatusurlxml);
I am trying to upload a file in chunks via Dropbox's API for PHP.
This is my code: This gives out the folowing error:
First few chunks are uploaded and then I get this error:-
Fatal error: Uncaught exception 'Dropbox\Exception_NetworkIO' with message 'Erro
r executing HTTP request: Failed to connect to api-content.dropbox.com port 443:
Connection refused' in /home/yashtk1/public_html/dropbox/Dropbox/Curl.php:69
Stack trace:
#0 /home/yashtk1/public_html/dropbox/Dropbox/Client.php(721): Dropbox\Curl->exec
()
#1 /home/yashtk1/public_html/dropbox/Dropbox/Client.php(602): Dropbox\Client->_c
hunkedUpload(Array, '`S\xCDb0\x80`\xA0\xD3\xB7\xEA\x07\xF1\xF7\xB4...')
#2 /home/yashtk1/public_html/dropbox/Dropbox/Client.php(437): Dropbox\Client->ch
unkedUploadContinue('jB2ZQWVyzMQgsX4...', 41943040, '`S\xCDb0\x80`\xA0\xD3\xB7\x
EA\x07\xF1\xF7\xB4...')
#3 /home/yashtk1/public_html/dropbox/Dropbox/RequestUtil.php(278): Dropbox\Clien
t->Dropbox\{closure}()
#4 /home/yashtk1/public_html/dropbox/Dropbox/Client.php(438): Dropbox\RequestUti
l::runWithRetry(3, Object(Closure))
#5 /home/yashtk1/public_html/dropbox/Dropbox/Client.php(381): Dropbox\Client->_u
ploadFileChunked('/ahmd1.zip', Object(Dropbox\WriteMode), Resource i in /home/ya
shtk1/public_html/dropbox/Dropbox/Curl.php on line 69
My script:-
<?php
echo "hi";
set_time_limit(0);
# Include the Dropbox SDK libraries
require_once "Dropbox/autoload.php";
use \Dropbox as dbx;
$appInfo = dbx\AppInfo::loadFromJsonFile("config");
$f = fopen("ahmd1.zip", "rb");
$dbxClient = new dbx\Client("Access code", "PHP-Example/1.0");
$mode = dbx\WriteMode::add();
$chunk = $dbxClient->uploadFileChunked("/ahmd1.zip", $mode, $f);
print_r($chunk);
//uploadFileChunked( string $path, Dropbox\WriteMode $writeMode, resource $inStream, integer|null $numBytes = null, integer|null $chunkSize = null );
fclose($f);
?>
Please can anyone point out the mistake ?
I am working with the UPS api and am having a difficult time debugging. I am getting the following stack trace:
Details
Type: SoapFault
Message: An exception has been raised as a result of client data.
File: /Users/shawn/Documents/work/sites/Wingspan/kaleco/lib/SixString/Utilities/Ups.php
Line: 161
Trace
#0 /Users/shawn/Documents/work/sites/Wingspan/kaleco/lib/SixString/Utilities/Ups.php(161): SoapClient->__soapCall('ProcessShipment', Array)
#1 /Users/shawn/Documents/work/sites/Wingspan/kaleco/routes/ups.php(14): SixString\Utilities\Ups->getShipment()
#2 [internal function]: {closure}()
#3 /Users/shawn/Documents/work/sites/Wingspan/kaleco/vendor/slim/slim/Slim/Router.php(172): call_user_func_array(Object(Closure), Array)
#4 /Users/shawn/Documents/work/sites/Wingspan/kaleco/vendor/slim/slim/Slim/Slim.php(1222): Slim\Router->dispatch(Object(Slim\Route))
#5 /Users/shawn/Documents/work/sites/Wingspan/kaleco/vendor/slim/slim/Slim/Middleware/Flash.php(86): Slim\Slim->call()
#6 /Users/shawn/Documents/work/sites/Wingspan/kaleco/vendor/slim/slim/Slim/Middleware/MethodOverride.php(94): Slim\Middleware\Flash->call()
#7 /Users/shawn/Documents/work/sites/Wingspan/kaleco/vendor/slim/slim/Slim/Middleware/SessionCookie.php(116): Slim\Middleware\MethodOverride->call()
#8 /Users/shawn/Documents/work/sites/Wingspan/kaleco/vendor/slim/slim/Slim/Middleware/PrettyExceptions.php(67): Slim\Middleware\SessionCookie->call()
#9 /Users/shawn/Documents/work/sites/Wingspan/kaleco/vendor/slim/slim/Slim/Slim.php(1174): Slim\Middleware\PrettyExceptions->call()
#10 /Users/shawn/Documents/work/sites/Wingspan/kaleco/public/index.php(6): Slim\Slim->run()
#11 {main}
Here is the block of code:
try{
$mode = array('soap_version' => 'SOAP_1_1', 'trace' => 1,'exceptions' => true );
$client = new \SoapClient($wsdl , $mode);
$client->__setLocation($endpointurl);
$header = new \SoapHeader('http://www.ups.com/XMLSchema/XOLTWS/UPSS/v1.0','UPSSecurity',$this->upss);
$client->__setSoapHeaders($header);
if(strcmp($operation,"ProcessShipment") == 0 ) {
$resp = $client->__soapCall('ProcessShipment',array($this->processShipment()));
echo "Response Status: " . $resp->Response->ResponseStatus->Description ."\n";
//print_r($client->__getLastRequest());
}
else if (strcmp($operation , "ProcessShipConfirm") == 0) {
$resp = $client->__soapCall('ProcessShipConfirm',array($this->processShipConfirm()));
echo "Response Status: " . $resp->Response->ResponseStatus->Description ."\n";
}
else {
$resp = $client->__soapCall('ProcessShipeAccept',array($this->processShipAccept()));
//get status
echo "Response Status: " . $resp->Response->ResponseStatus->Description ."\n";
echo "<pre>";
print_r($resp);
echo "</pre>";
}
}
catch(Exception $ex){
print_r ($ex);
}
Line 161 is in the above code, this is the actual line:
$resp = $client->__soapCall('ProcessShipConfirm',array($this->processShipConfirm()));
I am looking for a way to debug this. It does not appear to be reaching the catch block and I cannot seem to determine the cause of the exception.
Try to catch exception with SoapFault and print its detail property.
try {
$response = $client->$call( $params );
} catch (\SoapFault $fault) {
//trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR);
var_dump($fault->faultcode);
var_dump($fault->faultstring);
var_dump($fault->detail);
die('Errore chiamata webservice UPS');
}
refer to: http://php.net/manual/en/function.is-soap-fault.php
I don't know the nuances of exception handling in PHP, but Soap exceptions are squirrely little buggers in C# as well. In Visual Studio's debugger, you can get at the details of unhandled exceptions right in the IDE. If you have an option to do this, look for the exception's "detail" XML Element, as this will contain the web service's message telling you what was borked with your request.
As for actually trapping the exception, there's an old but good article by #Jeff Atwood that — though written for (gasp) VB.NET — might still provide some insight into what makes Soap exceptions so, er... slippery: Coding Horror | Throwing better SOAP exceptions
NOTE: For what it's worth, UPS gives this error for bad tracking numbers. Use a good (valid) tracking number and it corrected my issue.
UPS gives this error also for bad ShipFrom/CountryCode or ShipTo/CountryCode in Rates API. e.g. germany can't be rated. This can't found in the UPS dev docs.