Laravel 5.6 SoapClient not found - php

namespace App\lara;
use SoapClient;
use StdClass;
class abrLookup extends SoapClient {
private $guid = "xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx";
public function __construct()
{
$params = array(
'soap_version' => SOAP_1_1,
'exceptions' => true,
'trace' => 1,
'cache_wsdl' => WSDL_CACHE_NONE
);
Error
"Class 'SoapClient' not found"
I am trying to extend this class for however it is saying soap client not found, I am using php 7.2. I have went into my Apache and php setting and enabled the extension and looked up the php settings and it is enabled.
soap
Soap Client => enabled
Soap Server => enabled
Directive => Local Value => Master Value
soap.wsdl_cache => 1 => 1
soap.wsdl_cache_dir => /tmp => /tmp
soap.wsdl_cache_enabled => 1 => 1
soap.wsdl_cache_limit => 5 => 5
soap.wsdl_cache_ttl => 86400 => 86400
I then thought it was a laravel problem so i restarted the server and ran these commands
php artisan config:cache
php artisan config:clear
However i'm still where I started and clueless on how to resolve this issue, this is running on Ubuntu - php V7.2

When you call SoapClient don't forget to use the global namespace : https://www.php.net/manual/en/language.namespaces.global.php
use \SoapClient;

Related

Installing php-soap on nginx with multiple php versions

I am running a few sites that has different php versions running (7.0 and 7.4)
For one of the sites, when I try to run soap code, I get:
Uncaught Error: Class 'SoapClient' not found
When I run
php -i | grep -i soap
i get the following output:
/etc/php/7.4/cli/conf.d/20-soap.ini,
soap
Soap Client => enabled
Soap Server => enabled
soap.wsdl_cache => 1 => 1
soap.wsdl_cache_dir => /tmp => /tmp
soap.wsdl_cache_enabled => 1 => 1
soap.wsdl_cache_limit => 5 => 5
soap.wsdl_cache_ttl => 86400 => 86400
I need to install the soap for php 7.0 and I am not that familiar with linux so I would love to get some step by step instructions.
Thanks!

Class 'SoapClient' not found on Google Cloud PHP App

I deployed my php app to Google Cloud and getting currently the following error when i call the line.
$url = "S5WS.wsdl";
$client = new \SoapClient(dirname(__FILE__) . DIRECTORY_SEPARATOR . $url, array('trace' => true, 'soap_version' => SOAP_1_1));
PHP message:
PHP Fatal error: Class 'SoapClient' not found in /app/controllers/TicketController.php on line 211
I opened the terminal in the Google Cloud and typed php -i | grep -i soapso to check the status of the soap and it seemds to be fine.
baltacii#s5-app-****:/$ php -i | grep -i soap
soap
Soap Client => enabled
Soap Server => enabled
soap.wsdl_cache => 1 => 1
soap.wsdl_cache_dir => /tmp => /tmp
soap.wsdl_cache_enabled => 1 => 1
soap.wsdl_cache_limit => 5 => 5
soap.wsdl_cache_ttl => 86400 => 86400
baltacii#s5-app-167912:/$
If i call phpinfo(); in the app.It returns me in contrast to my localhost no Soap Section. There are only 2 lines related with the soap.
SOAP Brad Lafountain, Shane Caraveo, Dmitry Stogov
and in the configure command section
'--enable-soap=shared'
EDIT: App runs on PHP Version 5.6
So according to documentation some PHP extensions are compiled as shared, but disabled by default.Soap is one of these extensions.In order to activate it. We should create a php.ini in the base folder of the project.
php.ini
; Enable the Soap extension
extension=soap.so
After new deployment to server soap should be available.

PHP 7 and SOAP WSDL with SSL error

I'm using Wsdl2PhpGenerator to create my soap client; was was working fine with PHP v5.4, but now I've upgraded to PHP 7 I get an error:
Uncaught SoapFault: SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://sussexbedcentre.retailsystem.net/services/v2/GetCatalog.asmx?WSDL' : failed to load external entity
I have tried:
Connecting to a non SSL soap service - worked fine, so must be the SSL.
Every ssl_method
soap.wsdl_cache_enabled, soap.wsdl_cache_ttl, soap.wsdl_cache all set to 0
Verified openssl, soap, xmlrpc php extensions all loaded ok
PEM file and passphrase worked fine under PHP 5.4
Any ideas what else I can try to get to the bottom of this?
Code I'm using is:
$cert = 'rs_ssl.pem';
$generator = new \Wsdl2PhpGenerator\Generator();
$generator->generate(
new \Wsdl2PhpGenerator\Config(array(
'inputFile' => 'https://sussexbedcentre.retailsystem.net/services/v2/GetCatalog.asmx?WSDL',
'outputDir' => 'soapclass/',
'soapClientOptions' => array(
'local_cert' => $cert,
'passphrase' => '*******',
'connection_timeout' => 60,
'trace' => 1,
'soap_version' => SOAP_1_2
)
))
);
If I switch back to PHP 5.4 with the same code it works fine.
Thanks!

Zendframework 2 with memcache not working

I am trying to get memcache to work with Zendframework 2. How do I get Zendframework 2 to see memcache correct so I don't get the error I have listed below? I want to use memcache instead of memcached.
Error:
Exception - An abstract factory could not create an instance of memcache(alias: memcache).
Previous exceptions - An exception was raised while creating "memcache"; no instance returned
The option "liboptions" does not have a matching setLiboptions setter method which must be defined
I get this error when just trying to test it with this line in a controller
echo $this->getServiceLocator()->get('memcache')->getVersion();
Details:
I'm running windows 7 64 bit with a local instance of IIS7 up and running.
I used this guide to install memecache on my pc: How to Install Memcache on Windows 7
I verified the memcache service is up and running
I verified that using memecache outside of Zendframework 2 works.
So next I followed this guide to get it to work in Zendframework 2: How to setup Zendframework 2 to use Memcached I know this guide is for memcached and not memcache but I used it as a base
Troubleshooting I've done already:
Verified service is running
Verified phpinfo() shows the memcache section so I know the php extension is loading from the php.ini
Since I'm still hazy on memcache vs memcached I've tried setting the config files and above echo to try and use the string
'memcached' and 'memcache' to see if that would help find it, but
didn't work.
I read some things online about how a 'Di' thing can conflict with this. I verified my config does not load anything with 'Di'
Verified that the abstract factory setting is loaded in the config under Service Manager
Code:
config var_dump showing the abstract factory part is loading
$sm = $this->getServiceLocator();
$config = $sm->get('config');
var_dump($config);die();
'service_manager' =>
array (size=3)
'abstract_factories' =>
array (size=2)
0 => string 'Zend\Cache\Service\StorageCacheAbstractServiceFactory' (length=53)
1 => string 'Zend\Log\LoggerAbstractServiceFactory' (length=37)
'aliases' =>
array (size=2)
'translator' => string 'MvcTranslator' (length=13)
'db' => string 'Zend\Db\Adapter\Adapter' (length=23)
'factories' =>
array (size=1)
'Zend\Db\Adapter\Adapter' => string 'Zend\Db\Adapter\AdapterServiceFactory' (length=37)
My cache.local.php and it's in the autoload directory of zendframework 2 (taken from above tutorial link and removed the 'd')
I think this is what I need to change just not sure how....
return array(
'caches' => array(
'memcache' => array( //can be called directly via SM in the name of 'memcache'
'adapter' => array(
'name' =>'memcache',
'lifetime' => 86400, //24 hours
'options' => array(
'servers' => array(
array(
'127.0.0.1',11211 //Server IP, Port
)
),
'namespace' => 'MYMEMCACHENAMESPACE',
'liboptions' => array (
'COMPRESSION' => true,
'binary_protocol' => true,
'no_block' => true,
'connect_timeout' => 120
)
)
),
'plugins' => array(
'exception_handler' => array(
'throw_exceptions' => false
),
),
),
),
);
You need to install the PHP library memcached so you can use ZFs Memcached Adaptor. ZF does not have an adaptor for the memcache library so it's trying to use the library directly which does not have a setter for liboptions. Either install memcached or remove liboptions in your config and you should be all set.

Warning: SoapClient::SoapClient(http://www.w3.org/2005/05/xmlmime): failed to open stream: HTTP request failed! HTTP/1.1 401 Authorization Required

I have simple script connection call using PHP 5.2.10 to a Web service working with SOAP 1.2.
The same PHP installation is able to connect via Web service to another web server working with SOAP 1.1 without issues. In addition, the web services using 1.2 is working fine with another two servers using almost the same hard code.
However, every time I am using SOAP 1.2 on this server with PHP 5.2.10 I got the bellow error if I run the script from a batch file:
Warning: SoapClient::SoapClient(http://www.w3.org/2005/05/xmlmime): failed to open stream: HTTP request failed! HTTP/1.1 401 Authorization Required in C: \NewSimpleConnectionTest.php on line 10
If the script is running via Eclipse PHP with PHP 5.2 on a different computer, it does not have any error so the hard code seems fine, user and password are correct too because it is used on the others servers and on the Eclipse test:
My script is this:
<?php
$_endpoint = "http://server:8080/serverv/ServerAPI";
$_username = "userServer";
$_password = "123ABC!";
try
{
$client = new SoapClient($_endpoint."?WSDL", array('location' => $_endpoint, 'login' => $_username, 'password' => $_password, 'trace' => 1, 'features' => SOAP_USE_XSI_ARRAY_TYPE + SOAP_SINGLE_ELEMENT_ARRAYS, 'soap_version' => SOAP_1_2));
echo 'Connected to Web Services.';
}catch(Exception $e){
echo 'Failure to connect to WebServices.';
}
?>
This is the information in the SOAP and XML phpinfo.
SimpleXML
Simplexml support => enabled
Revision => $Revision: 1.151.2.22.2.46 $
Schema support => enabled
soap
Soap Client => enabled
Soap Server => enabled
Directive => Local Value => Master Value
soap.wsdl_cache => 1 => 1
soap.wsdl_cache_dir => /tmp => /tmp
soap.wsdl_cache_enabled => 1 => 1
soap.wsdl_cache_limit => 5 => 5
soap.wsdl_cache_ttl => 86400 => 86400
Any idea about what is missing or the problem on this PHP version to work with SOAP 1.2 in that server?
Thanks in advance!!
After some hours working around this problem, the solution was changing the version of PHP from 5.2.10 to 5.5.28.
There is some kind of bug on this old version and prevent the correct connection with SOAP 1.2.
I hope this help someone using this old version of PHP.

Categories