SOAP: Fatal Error .. Could not connect to host - php

I've tried everything I can think of to no avail, and hope you can help.
I've taken on a site from another web dev, so am working on existing code.
The code works on my own development server (debian VM on my Win7 machine), but not on the live server (WHM/cPanel admin'd REDHAT Enterprise 5.4 x86_64 standard).
I get the following error after the call to $BHclient->startSession:
Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to host in /home/aap3r/public_html/soap_test.php:60
Stack trace:
#0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'https://api.bul...', '', 1, 0)
#1 /home/aap3r/public_html/soap_test.php(60): SoapClient->__call('startSession', Array)
#2 /home/aap3r/public_html/soap_test.php(60): SoapClient->startSession(Object(stdClass))
#3 {main}
thrown in /home/aap3r/public_html/soap_test.php on line 60
The WDSL file is downloaded okay (though it appears to have the wrong mime-type).
Since the exact same test code works on one server but not another I thought it was a firewall issue, but the host denies it.
The relevant code:
$url = "http://api.bullhornstaffing.com/webservices-2.0/?wsdl";
ini_set('soap.wsdl_cache_enabled',1);
ini_set('soap.wsdl_cache_ttl',1);
$username = "xxx";
$password = "xxx";
$apiKey = "xxxx";
$session_request = new stdClass();
$session_request->username = $username;
$session_request->password = $password;
$session_request->apiKey = $apiKey;
$BHclient = new SoapClient($url, array("trace" => true, "exception" => false));
$API_session = $BHclient->startSession($session_request);
print_r($API_session);
phpinfo confirms that SOAP is installed, and I've tried the various implementation/installation methods presented in the control panels.
I've updated to PHP Version 5.3.27 and Apache to 2.2.25.
Any help will be hugely appreciated.
Update: I've found a workaround. For whatever reason the production server couldn't connect to HTTP*S*, so I copied and rehosted the WDSL file after manually editing it to replace the protocol.

I would record the network traffic with tcpdump:
tcpdump -s65535 -iYOUR_INTERFACE -w soap.pcap
You can analyze the traffic (soap.pcap) using wireshark.

Related

Zend Framework - Fatal error: Uncaught exception 'Zend_Mail_Protocol_Exception'

can someone help?
I have issue with sending mail from website (eshop) after order confirmation.
Zend fremework is used to 2 identically eshop. Both use the same classes, same settings, on one it works fine and on the other one crashes with this error:
Settings:
Zend framework, Eshop, PHP version 5.3
MAIL
mail.encoding = UTF-8
mail.useSmtp = true
mail.smtp.server = mail.*******.**
mail.smtp.port = 465
mail.smtp.ssl = ssl
mail.smtp.auth = login
mail.smtp.username = #.**
mail.smtp.password = **********
ISSUE
Fatal error: Uncaught exception 'Zend_Mail_Protocol_Exception' with message 'No connection has been established to mail8.hostmaster.sk' in /home/hn003000/www_root/ShibumiFramework/Zend/Mail/Protocol/Abstract.php:312 Stack trace:
#0 /home/hn003000/www_root/ShibumiFramework/Zend/Mail/Protocol/Abstract.php(370): Zend_Mail_Protocol_Abstract->_receive(300)
#1 /home/hn003000/www_root/ShibumiFramework/Zend/Mail/Protocol/Smtp.php(199): Z Zend_Mail_Protocol_Abstract->_expect(220, 300)
#2/home/hn003000/www_root/ShibumiFramework/Zend/Mail/Transport/Smtp.php(198): Z Ze Znd_Mail_Protocol_Smtp->helo('localhost')
#3 /home/hn003000/www_root/ShibumiFramework/Zend/Mail/Transport/Abstract.php(349): Zend_Mail_Transport_Smtp->_sendMail()
#4/home/hn003000/www_root/ShibumiFramework/Zend/Mail.php(960): Zend_Mail_Transport_Abstract->send(Object(Shibumi_Mail))
#5/home/hn003000/www_root/ShibumiFramework/Shibumi/Mail.php(27): Zend_Mail->send(Object(Zend_Mail_Transport_Smtp))
#6 /home/hn003000/www_root/www_akva24/application/modules/catalog/controllers/ in /home/hn003000/www_root/ShibumiFramework/Zend/Mail/Protocol/Abstract.php on line 312
Thanks for answers
I tried change to TLS
I tried another mail server
Requests did not arrive on the mail server
My hosting privider blocked php mail function on my site!
After they fixed it (a week of convincing that the fault is with them) it works.
Thanks, solved

ODOO Web Service API is not working by using PHP code given in odoo web services API

I am using the following php code to connect odoo web services by using the below link
https://www.odoo.com/documentation/9.0/api_integration.html
$url = "http://188.166.242.45:8069/";
$db = "test_db";
$username = "admin";
$password = "admin";
require_once('ripcord-master/ripcord.php');
$info = ripcord::client('http://188.166.242.45:8069/')->start();
list($url, $db, $username, $password) =
array($info['host'], $info['database'], $info['user'], $info['password']);
But this shows the below error.
Fatal error: Uncaught exception 'Ripcord_TransportException' with message 'Could not access http://188.166.242.43:8069/' in D:\xampp\htdocs\web_services\ripcord-master\ripcord_client.php:488 Stack trace: #0 D:\xampp\htdocs\web_services\ripcord-master\ripcord_client.php(228): Ripcord_Transport_Stream->post('http://188.166....', '<?xml version="...') #1 D:\xampp\htdocs\web_services\index.php(10): Ripcord_Client->__call('start', Array) #2 D:\xampp\htdocs\web_services\index.php(10): Ripcord_Client->start() #3 {main} thrown in D:\xampp\htdocs\web_services\ripcord-master\ripcord_client.php on line 488
How can I resolve this???
Well, the link: https://www.odoo.com/documentation/9.0/api_integration.html shows the Php code for making the Api call. It uses the ripcord xmlrpc Php library. The example shows the url as: https://demo.odoo.com/start. Your url does not include the /start. Try to use this url: http://188.166.242.45:8069/start. Have you installed the Odoo on port 8069?.
The note below the example says that the ripcord library requires the phpxmlrpc and openssl extensions. It also requires https for the api url

No route to host error while login using google plus in PHP

I wanted Google plus login in my PHP website. I tried to integrate it from : http://www.codexworld.com/login-with-google-api-using-php
When I try to login, It throws error:
Fatal error: Uncaught exception 'Google_IOException' with message 'HTTP Error: (0) Failed to connect to accounts.google.com port 443: No route to host' in /home/thewiref/public_html/mastkids.in/test_google/src/io/Google_CurlIO.php:128 Stack trace: #0 /home/thewiref/public_html/mastkids.in/test_google/src/auth/Google_OAuth2.php(101): Google_CurlIO->makeRequest(Object(Google_HttpRequest)) #1 /home/thewiref/public_html/mastkids.in/test_google/src/Google_Client.php(131): Google_OAuth2->authenticate(Array, NULL) #2 /home/thewiref/public_html/mastkids.in/test_google/index.php(8): Google_Client->authenticate() #3 {main} thrown in /home/thewiref/public_html/mastkids.in/test_google/src/io/Google_CurlIO.php on line 128
Same code is working perfect in different domain and server. So what could be issue in this server?
Check your Firewall settings and network connectivity to see if you are able to connect to the network.
Try running the following
<?php
$read = file_get_contents("https://google.com");
echo $read;
If you are able to see the google page(even if it is distorted).
If not then your system has a network connectivity issue or DNS issues.

Twilio SMS api failed throw exception on XAMPP any port or IP to be oppened

I integrate Twilio SMS API on PHP. And the code is working on GoDaddy hosting. But not working on local XAMPP. When I use open network it is working fine. But under company net work it is failing. Is there any port or IP to be opened on fire wall? Following is the code used.
require_once ("inc/Services/Twilio.php");
$strFromNumber = "+44xxxxxxxx";
$strToNumber = "+94xxxxxxxx";
$strMsg = "SMS test from twilio :".date('Y-m-d H:i:s');
$aryResponse = array();
$AccountSid = "ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx15";
$AuthToken = "0bxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxb1";
$objConnection = new Services_Twilio($AccountSid, $AuthToken);
try {
$bSuccess = $objConnection->account->sms_messages->create($strFromNumber,$strToNumber,$strMsg);
} catch (Services_Twilio_RestException $e) {
echo $e->getMessage();
}
$aryResponse["SentMsg"] = $strMsg;
$aryResponse["Success"] = true;
echo json_encode($aryResponse);
The error shown on local machine.
Fatal error: Uncaught exception 'Services_Twilio_TinyHttpException' with message 'SSL certificate problem: self signed certificate in certificate chain' in C:\xampp\htdocs\SMS\inc\Services\Twilio\TinyHttp.php:84 Stack trace: #0 C:\xampp\htdocs\SMS\inc\Services\Twilio.php(112): Services_Twilio_TinyHttp->__call('post', Array) #1 C:\xampp\htdocs\SMS\inc\Services\Twilio.php(112): Services_Twilio_TinyHttp->post('/2010-04-01/Acc...', Array, 'From=%2B4474813...') #2 C:\xampp\htdocs\SMS\inc\Services\Twilio\ListResource.php(89): Services_Twilio->createData('Accounts/AC6133...', Array) #3 C:\xampp\htdocs\SMS\inc\Services\Twilio\CachingDataProxy.php(115): Services_Twilio_ListResource->createData('AC6133e1339b600...', Array) #4 C:\xampp\htdocs\SMS\inc\Services\Twilio\Resource.php(44): Services_Twilio_CachingDataProxy->createData('SMS/Messages', Array) #5 C:\xampp\htdocs\SMS\inc\Services\Twilio\ListResource.php(59): Services_Twilio_Resource->createData('SMS/Messages', Array) #6 C:\xampp\htdocs\SMS\inc\Services\Twilio\Rest\SmsMessages. in C:\xampp\htdocs\SMS\inc\Services\Twilio\TinyHttp.php on line 84
How to fix this issue on local windows based XAMPP? What is the port or IP need to be opened to allow this service over restricted net work?
The isue is documented here:
https://support.twilio.com/hc/en-us/articles/235279367-Twilio-PHP-helper-library-SSL-certificate-problem-on-Windows
There is an issue with the php_curl library on Windows. It doesn't use an up-to-date list of CA Root Certificates. You can get a pem file of the root certificates from the curl site.
To fix this issue please try the following:
Download the following pem file: https://curl.haxx.se/ca/cacert.pem
Copy this file to c:\cert\cacert.pem
Open php.ini file in your favorite editor (see here on where to find it)
If the following configuration string: curl.cainfo exists in your php.ini, please uncomment it by removing ";" and modify the path in order to point it to the cacert.pem file you downloaded, e.g:
;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;
curl.cainfo=c:\cert\cacert.pem
Please restart your Apache or IIS service to apply the change (very important!)
Please give that a try and let me know if it works for you.

PHP - Cannot get SOAP server to work

I have written a very simple SOAP Server to check access to the server but I'm getting an error.
The server is a brand new VM of Windows Server 2008R2 (which I installed today to check this) I then installed WAMP which is working correctly. I think the issue is more of a configuration one but I'm no expert from here so need some help finding it.
I have enabled SOAP in WAMP. The WSDL is fine, I have checked it on a hosted server and it works as expected along with the server and client php files.
The error received at the client:
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL:
Couldn't load from './Soaptest.wsdl' : failed to load external entity "./Soaptest.wsdl" in
C:\wamp\www\Connector\Testing\c20\c20simpleClient.php:7
Stack trace: #0 C:\wamp\www\Connector\Testing\c20\c20simpleClient.php(7):
SoapClient->SoapClient('./c20simpleSoap...') #1 {main} thrown in
C:\wamp\www\Connector\Testing\c20\c20simpleClient.php on line 7
The Soap Server:
function Test(){
return true;
}
$server = new SoapServer("Soaptest.wsdl");
$server->addFunction("Test");
$server->handle();
The client (Line 6+):
$url = "./Soaptest.wsdl";
$client = new SoapClient($url);
echo "client created<br>";
$result = $client->Test();
echo "<hr>Method Test: <pre>".(string)$result."</pre>";
Aside from enabling soap in the php config, is there anything I need to do in Apache or php to enable SOAP?

Categories