I have looked through almost all existing threads, but I still can't find the problem, so I decided post a new one.
I have code that is running on my live server and the email function is working perfectly fine. It was setup by a contractor and he left no documentation on how to setup CakePHP.
I need to setup my staging server to work exactly the same as the live server. I think I have everything working, except for the email functions. Since I am running exactly the same code on both servers, I am positive that I have missed installing something or setting up configuration on my staging server.
So, what is the framework/module/library needed for CakeEmail? What is the configuration needed for it?
I am running at CakePHP 2.3.4
Here's my code snippet:
App::uses('CakeEmail', 'Network/Email');
$emailTest = new CakeEmail('default');
$emailTest->to('MyEmail#gmail.com');
$emailTest->from(array('me#example.com' => 'My Site'));
$emailTest->subject('About');
try {
$emailTest->send('Hey');
}
catch (SocketException $e) {
echo("Exception: " . $e->getMessage() . "\r\n");
echo("File: " . $e->getFile() . "\r\n");
echo("Line: " . $e->getLine() . "\r\n");
echo("Trace: " . $e->getTraceAsString() . "\r\n");
}
In email.php:
public $default = array(
'transport' => 'Mail',
'from' => 'notification#MySite.com',
// 'charset' => 'utf-8',
// 'headerCharset' => 'utf-8',
);
And I am getting this stack trace:
Exception: Could not send email.
File: /var/www/MySite/lib/Cake/Network/Email/MailTransport.php
Line: 70
Trace: 0 /var/www/MySite/lib/Cake/Network/Email/MailTransport.php(47): MailTransport->_mail('staging#gmail.c...', 'hsbsv vdbeh lik...', 'hsbsv vdbeh lik...', 'From: MySite...', NULL)
1 /var/www/MySite/lib/Cake/Network/Email/CakeEmail.php(1071): MailTransport->send(Object(CakeEmail))
2 /var/www/MySite/app/Model/Notification.php(238): CakeEmail->send('hsbsv vdbeh lik...')
3 [internal function]: Notification->afterSave(true, Array)
4 /var/www/MySite/lib/Cake/Event/CakeEventManager.php(246): call_user_func_array(Array, Array)
5 /var/www/MySite/lib/Cake/Model/Model.php(1772): CakeEventManager->dispatch(Object(CakeEvent))
6 /var/www/MySite/app/Controller/CommentsController.php(160): Model->save(Array)
7 [internal function]: CommentsController->add()
8 /var/www/MySite/lib/Cake/Controller/Controller.php(486): ReflectionMethod->invokeArgs(Object(CommentsController), Array)
9 /var/www/MySite/lib/Cake/Routing/Dispatcher.php(187): Controller->invokeAction(Object(CakeRequest))
10 /var/www/MySite/lib/Cake/Routing/Dispatcher.php(162): Dispatcher->_invoke(Object(CommentsController), Object(CakeRequest), Object(CakeResponse))
11 /var/www/MySite/app/webroot/index.php(109): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
12 {main}
Related
I need to update all media in a larger Shopware shop, with about 10000 products. I use the Shopware php SDK by vienthuong. I download 200 product objects at a time, create an upsert with their cover media id within a while loop.
It all goes well and good for about 2000 products. Then, nothing happens for a while, and then I get a "cURL error 6: Could not resolve host after resolving host before":
Fatal error: Uncaught GuzzleHttp\Exception\ConnectException: cURL error 6: Could not resolve host: foo-shop.de (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://glogner-shop.de/api/oauth/token in /Users/m/Desktop/updater-dev/coverImage/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:210
Stack trace:
#0 /Users/m/Desktop/updater-dev/coverImage/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(158): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array)
#1 /Users/m/Desktop/updater-dev/coverImage/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php(110): GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory))
#2 /Users/m/Desktop/updater-dev/coverImage/vendor/guzzlehttp/guzzle/src/Handler/CurlHandler.php(47): GuzzleHttp\Handler\CurlFactory::finish(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory))
#3 /Users/m/Desktop/updater-dev/coverImage/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php(67): GuzzleHttp\Handler\CurlHandler->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#4 /Users/m/Desktop/updater-dev/coverImage/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php(114): GuzzleHttp\RetryMiddleware->__invoke(Object(GuzzleHttp\Psr7\Request), Array)
#5 /Users/m/Desktop/updater-dev/coverImage/vendor/guzzlehttp/guzzle/src/RetryMiddleware.php(106): GuzzleHttp\RetryMiddleware->doRetry(Object(GuzzleHttp\Psr7\Request), Array)
#6 /Users/m/Desktop/updater-dev/coverImage/vendor/guzzlehttp/promises/src/RejectedPromise.php(42): GuzzleHttp\RetryMiddleware->GuzzleHttp\{closure}(Object(GuzzleHttp\Exception\ConnectException))
#7 /Users/m/Desktop/updater-dev/coverImage/vendor/guzzlehttp/promises/src/TaskQueue.php(48): GuzzleHttp\Promise\RejectedPromise::GuzzleHttp\Promise\{closure}()
#8 /Users/m/Desktop/updater-dev/coverImage/vendor/guzzlehttp/promises/src/Promise.php(248): GuzzleHttp\Promise\TaskQueue->run(true)
#9 /Users/m/Desktop/updater-dev/coverImage/vendor/guzzlehttp/promises/src/Promise.php(224): GuzzleHttp\Promise\Promise->invokeWaitFn()
#10 /Users/m/Desktop/updater-dev/coverImage/vendor/guzzlehttp/promises/src/Promise.php(269): GuzzleHttp\Promise\Promise->waitIfPending()
#11 /Users/m/Desktop/updater-dev/coverImage/vendor/guzzlehttp/promises/src/Promise.php(226): GuzzleHttp\Promise\Promise->invokeWaitList()
#12 /Users/m/Desktop/updater-dev/coverImage/vendor/guzzlehttp/promises/src/Promise.php(62): GuzzleHttp\Promise\Promise->waitIfPending()
#13 /Users/m/Desktop/updater-dev/coverImage/vendor/guzzlehttp/guzzle/src/Client.php(187): GuzzleHttp\Promise\Promise->wait()
#14 /Users/m/Desktop/updater-dev/coverImage/vendor/vin-sw/shopware-sdk/src/Client/Client.php(108): GuzzleHttp\Client->request('POST', 'https://glogner...', Array)
#15 /Users/m/Desktop/updater-dev/coverImage/vendor/vin-sw/shopware-sdk/src/Client/Client.php(135): Vin\ShopwareSdk\Client\Client->request('POST', 'https://glogner...', Array)
#16 /Users/m/Desktop/updater-dev/coverImage/vendor/vin-sw/shopware-sdk/src/Client/AdminAuthenticator.php(56): Vin\ShopwareSdk\Client\Client->post('https://glogner...', Array)
#17 /Users/m/Desktop/updater-dev/coverImage/token.php(15): Vin\ShopwareSdk\Client\AdminAuthenticator->fetchAccessToken()
#18 /Users/m/Desktop/updater-dev/coverImage/main.php(61): require('/Users/miamahnc...')
#19 {main}
thrown in /Users/m/Desktop/updater-dev/coverImage/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php on line 210
So, the error is telling me that it can't get the auth token, which worked fine before.
Code:
$time_pre = microtime(true);
require __DIR__ . '/token.php';
$criteria = new Criteria(1, 200);
$criteria->setTotalCountMode(1);
$criteria->addInclude('product', ["coverId"]);
$page_count = 1;
$total_product_count = 0;
do{
$context = new Context($config['shop_url'], $accessToken);
$syncService = new SyncService($context);
$data = [];
$payload = new SyncPayload();
$productRepository = RepositoryFactory::create(ProductDefinition::ENTITY_NAME);
$products = $productRepository->search($criteria, $context); //EntitySearchResult
$criteria->setPage($page_count);
if(microtime(true) >= $time_pre+(10*50) ){
echo "getting new token! \n";
$time_pre = microtime(true);
require __DIR__ . '/token.php';
$context = new Context($config['shop_url'], $accessToken);
$syncService = new SyncService($context);
}
$total_product_count += $products->count();
foreach( $products->getEntities()->getElements() as $key => $entity){
$ci = $entity->coverId;
if(!is_null($ci)){
$data[] = array('id' => $ci, 'position' => 0);
}
}
$payload->set(ProductMediaDefinition::ENTITY_NAME . '-upsert', new SyncOperator(ProductMediaDefinition::ENTITY_NAME, SyncOperator::UPSERT_OPERATOR,
$data
));
if(microtime(true) >= $time_pre+(10*50) ){
echo "getting new token! \n";
$time_pre = microtime(true);
require __DIR__ . '/token.php';
$context = new Context($config['shop_url'], $accessToken);
$syncService = new SyncService($context);
}
$response = $syncService->sync($payload);
++$page_count;
}while($products->getMeta()->getTotal() - $total_product_count > 0);
It's not that pretty anymore, but I just want it to work first.
I want to edit caption of photo, but Im getting error Bad Request: message to edit not found
Code :
<?php
require_once 'Telegram.php';
$telegram = new Telegram('bot:TOken');
$result = $telegram->getData();
$text = $result['message'] ['text'];
$chat_id = $result['message'] ['chat']['id'];
$messageID = $result['message']['message_id'];
$content = array('chat_id' => $chat_id, 'message_id' => $messageID, 'caption' => "wadawd");
// $content = array('chat_id' => $chat_id, 'text' => $messageID);
$telegram->editMessageCaption($content);
Error Log :
============[Date]============
[ 2022-02-28 12:36:58 UTC ]
==========[Response]==========
ok: False
error_code: 400
description: Bad Request: message to edit not found
=========[Sent Data]==========
[ref]
ref.update_id= 3618619
ref.message.message_id= 42
ref.message.from.id= 52868936
ref.message.from.is_bot= false
ref.message.from.first_name= Ramana
ref.message.from.last_name= Owner
ref.message.from.language_code= en
ref.message.chat.id= 52868936
ref.message.chat.first_name= Ramana
ref.message.chat.last_name= Owner
ref.message.chat.type= private
ref.message.date= 1646051816
ref.message.text= esfsef
[ref]
ref.message_id=
ref.caption= wadawd
============[Trace]===========
#0 /home/onbvbrh08q4z/public_html/captionbot/Telegram.php(3228): TelegramErrorLogger::log()
#1 /home/onbvbrh08q4z/public_html/captionbot/Telegram.php(111): Telegram->sendAPIRequest()
#2 /home/onbvbrh08q4z/public_html/captionbot/Telegram.php(1633): Telegram->endpoint()
#3 /home/onbvbrh08q4z/public_html/captionbot/test.php(15): Telegram->editMessageCaption()
#4 {main}
I'm using this github repo https://github.com/Eleirbag89/TelegramBotPHP
Bots (using api.telegram.org) cannot edit messages of posts made before the bot was added to the channel.
Hence, Telegram Bot Api shows you the error "message to edit not found"
When using the following connection script:
<?php
ini_set('default_socket_timeout', 120);
$soap_connection_info = array(
'soap_uri' => 'urn:AC',
'soap_host' => '127.0.0.1',
'soap_port' => '7878',
'account_name' => 'acore',
'account_password' => 'password'
);
function RemoteCommandWithSOAP($username, $password, $COMMAND)
{
global $soap_connection_info;
$result = '';
try {
$conn = new SoapClient(NULL, array(
'location' => 'http://' . $soap_connection_info['soap_host'] . ':' . $soap_connection_info['soap_port'] . '/',
'uri' => $soap_connection_info['soap_uri'],
'style' => SOAP_RPC,
'login' => $username,
'password' => $password,
'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | SOAP_COMPRESSION_DEFLATE,
));
$result = $conn->executeCommand(new SoapParam($COMMAND, 'command'));
unset($conn);
} catch (Exception $e) {
$result = "\nHave error on soap!\n" . $e . "\n";
if (strpos($e, 'There is no such command') !== false) {
$result = 'There is no such command!';
}
}
return $result;
}
echo RemoteCommandWithSOAP($soap_connection_info['account_name'], $soap_connection_info['account_password'], ".server info");
?>
With the world server running and listening to port 7878, I get:
local-iMac $ php test.php
Have error on soap!
SoapFault exception: [HTTP] Error Fetching http headers in /Users/dan/dev/test.php:26
Stack trace:
#0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'http://127.0.0....', 'urn:AC#executeC...', 1, false)
#1 /Users/dan/dev/test.php(26): SoapClient->__call('executeCommand', Array)
#2 /Users/dan/dev/test.php(39): RemoteCommandWithSOAP('acore', 'password', '.server info')
#3 {main}
I know error fetching headers points to a possible timeout when waiting for a response but this error comes up instantly as if there was no wait. However I added in the ini_set('default_socket_timeout', 120); in my script just to be sure.
My worldserver.conf:
# - the DB hostname will be the name of the database docker container
LoginDatabaseInfo = "ac-database;3306;root;password;acore_auth"
WorldDatabaseInfo = "ac-database;3306;root;password;acore_world"
CharacterDatabaseInfo = "ac-database;3306;root;password;acore_characters"
# Add more configuration overwrites by copying settings from worldserver.conf.dist
LogLevel = 5
Appender.File=2,5,7,debug.log,w
Logger.network.soap=5,File
Logger.server.worldserver=5,File
# Disable idle connections automatic kick since it doesn't work well on macOS + Docker
CloseIdleConnections = 0
Updates.EnableDatabases = 1
Death.SicknessLevel = -10
SOAP.Enabled = 1
SOAP.IP = "127.0.0.1"
SOAP.Port = 7878
And my docker-compose is unchanged:
https://github.com/azerothcore/azerothcore-wotlk/blob/master/docker-compose.yml
Interestingly if I down the world container I will get a different response as if it was connecting when it was up.
local-iMac $ php test.php
Have error on soap!
SoapFault exception: [HTTP] Could not connect to host in /Users/dan/dev/test.php:26
Stack trace:
#0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'http://127.0.0....', 'urn:AC#executeC...', 1, false)
#1 /Users/dan/dev/test.php(26): SoapClient->__call('executeCommand', Array)
#2 /Users/dan/dev/test.php(39): RemoteCommandWithSOAP('acore', 'password', '.server info')
#3 {main}
Also I enabled worldserver logs to see what was going on in SOAP:
2021-09-23_20:41:17 INFO [server.worldserver] > Using configuration file /azerothcore/env/dist/etc/worldserver.conf
2021-09-23_20:41:17 INFO [server.worldserver] > Using SSL version: OpenSSL 1.1.1f 31 Mar 2020 (library: OpenSSL 1.1.1f 31 Mar 2020)
2021-09-23_20:41:17 INFO [server.worldserver] > Using Boost version: 1.71.0
2021-09-23_20:41:17 INFO [server.worldserver]
2021-09-23_20:41:17 INFO [server.worldserver] Process priority class set to -15
2021-09-23_20:41:31 INFO [network.soap] ACSoap: bound to http://127.0.0.1:7878
Also I know container is correctly listening to the port:
f166a28ffdf5 acore/ac-wotlk-worldserver-local:master "./acore.sh run-worl…" 3 weeks ago Up 48 minutes 0.0.0.0:7878->7878/tcp, :::7878->7878/tcp, 0.0.0.0:8085->8085/tcp, :::8085->8085/tcp azerothcore-wotlk_ac-worldserver_1
Some stats on my local:
MacOS Mojave 10.14.6
local-iMac $ docker -v
Docker version 20.10.7, build f0df350
local-iMac $ php -v
PHP 8.0.10 (cli) (built: Aug 26 2021 15:37:37) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.10, Copyright (c) Zend Technologies
with Zend OPcache v8.0.10, Copyright (c), by Zend Technologies
Docker acts like a DHCP server and assigns IP's to the containers. You need to check for what the 'local' IP is and that means 'local' to docker.
docker inspect <containerID> | grep IPAddress
That is the ip you need to bind to in your config.
SOAP.Enabled = 1
SOAP.IP = "172.19.0.3"
SOAP.Port = 7878
$transport = Swift_SendmailTransport::newInstance();
$mailer = \Swift_Mailer::newInstance($transport);
$message = \Swift_Message::newInstance();
$message->setSubject('Email From Our Website');
$message->setFrom(array(
$cleanEmail => $cleanName
));
$message->setTo(array('talhagillani96#gmail.com'));
$message->setBody($cleanMessage);
$result = $mailer->send($message);
if($result > 0) {
$app->flash('success', 'Thanks So Much! You are AWESOME!!!');
$app->redirect('/');
} else {
$app->flash('fail', 'So Sorry, Something Went Wrong.Try Again!');
// log that there was an error
$app->redirect('/contact');
}
Slim Application Error The application could not run because of the following error:
Details Type: Swift_TransportException Message: Process could not be started [The system cannot find the path specified. ]
File: C:\xampp\htdocs\Projects\php2015\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\StreamBuffer.php Line: 294 Trace #0 C:\xampp\htdocs\Projects\php2015\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\StreamBuffer.php(58): Swift_Transport_StreamBuffer->_establishProcessConnection() #1 C:\xampp\htdocs\Projects\php2015\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\AbstractSmtpTransport.php(113): Swift_Transport_StreamBuffer->initialize(Array) #2 C:\xampp\htdocs\Projects\php2015\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\SendmailTransport.php(51): Swift_Transport_AbstractSmtpTransport->start() #3 C:\xampp\htdocs\Projects\php2015\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Mailer.php(79): Swift_Transport_SendmailTransport->start() #4 C:\xampp\htdocs\Projects\php2015\index.php(41): Swift_Mailer->send(Object(Swift_Message)) #5 [internal function]: {closure}() #6 C:\xampp\htdocs\Projects\php2015\vendor\slim\slim\Slim\Route.php(468): call_user_func_array(Object(Closure), Array) #7 C:\xampp\htdocs\Projects\php2015\vendor\slim\slim\Slim\Slim.php(1357): Slim\Route->dispatch() #8 C:\xampp\htdocs\Projects\php2015\vendor\slim\slim\Slim\Middleware\Flash.php(85): Slim\Slim->call() #9 C:\xampp\htdocs\Projects\php2015\vendor\slim\slim\Slim\Middleware\MethodOverride.php(92): Slim\Middleware\Flash->call() #10 C:\xampp\htdocs\Projects\php2015\vendor\slim\slim\Slim\Middleware\SessionCookie.php(110): Slim\Middleware\MethodOverride->call() #11 C:\xampp\htdocs\Projects\php2015\vendor\slim\slim\Slim\Middleware\PrettyExceptions.php(67): Slim\Middleware\SessionCookie->call() #12 C:\xampp\htdocs\Projects\php2015\vendor\slim\slim\Slim\Slim.php(1302): Slim\Middleware\PrettyExceptions->call() #13 C:\xampp\htdocs\Projects\php2015\index.php(53): Slim\Slim->run() #14 {main}
Based on this answer:
Use
$transport = Swift_MailTransport::newInstance();
instead of Swift_SendmailTransport.
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.