Question

In Magento 1.7.0.2, I have created an event listener that triggers every time the application checks the final price of a product (the final code will not trigger on that event, but for testing convenience, I am trying here).

The event triggers just fine and changes the price accordingly, but when I try to create a nusoap object to make non-wsdl calls to an external webservice, it raises a warning and does not create the client object.

The code is:

    $endpoint = 'http://[ip]:155/[client_name]/[client_name].soap2';

    try {
        $client = new nusoap_client($endpoint);
    } catch (Exception $e) {
        echo $e->getMessage();
    }

And the warning raised:

Warning: include(Nusoap/Client.php) 
[<a href="function.include">function.include</a>]: 
failed to open stream: No such file or directory  in 
/var/www/clients/client3/magento/lib/Varien/Autoload.php on line 93

The same code works fine if executed on the Magento root directory, where I was able to even call the correct webservice and parse the response.

I have included the nusoap libraries (v. 0.9.5) in the Magento root lib directory, and I have not required them specifically.

Was it helpful?

Solution

You've already identified your problem

I have included the nusoap libraries (v. 0.9.5) in the Magento root lib directory and I have not required them specifically

When you attempt to instantiate an object using the nusoap_client class, PHP can't find the class. Per standard behavior, it calls the Magento autoloader method, which converts the class nusoap_client into the file path Nusoap/Client.php, and then attempts to include that file. PHP, per standard include behavior, looks for files at

app/code/local/Nusoap/Client.php
app/code/community/Nusoap/Client.php
app/code/core/Nusoap/Client.php
lib/Nusoap/Client.php
path/of/the/calling/script/Nusoap/Client.php

You don't have a file at any of these locations, so PHP raises a warning. Manually require your nusoap object, placed a loader for the objects at one of the above paths, or add a custom autoloader that handles your library location.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top