Question

I have updated my Magento Store from 1.9.2.4 to 1.9.3.0

We use shipping software (Shipworks) that connects via a SOAP/XML-RPC user.

After the update shipworks logging shows this response in the logs:

<?xml version="1.0" encoding="UTF-8"?>
-<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
-<SOAP-ENV:Body>
-<SOAP-ENV:Fault>
<faultcode>1</faultcode>
<faultstring>Internal Error. Please see log for details.</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

So I went and turned on exception logging in Magento and get the following error:

2016-10-13T18:24:14+00:00 ERR (3): 
SoapFault exception: [1] Internal Error. Please see log for details. in /public_html/app/code/core/Mage/Api/Model/Server/Adapter/Soap.php:196
Stack trace:
#0 /public_html/app/code/core/Mage/Api/Model/Server/Handler/Abstract.php(140): Mage_Api_Model_Server_Adapter_Soap->fault('1', 'Internal Error....')
#1 /public_html/app/code/core/Mage/Api/Model/Server/Handler/Abstract.php(48): Mage_Api_Model_Server_Handler_Abstract->_fault('internal')
#2 /public_html/app/code/core/Mage/Api/Model/Server/Handler/Abstract.php(559): Mage_Api_Model_Server_Handler_Abstract->handlePhpError(4096, 'Argument 1 pass...', '/home/deepsix/p...', 559, Array)
#3 /public_html/app/code/core/Mage/Api/Model/Server/Handler/Abstract.php(299): Mage_Api_Model_Server_Handler_Abstract->processingMethodResult('<?xml version="...')
#4 [internal function]: Mage_Api_Model_Server_Handler_Abstract->call('ca4d34d100c92c8...', 'shipWorksApi.ge...', Array)
#5 /public_html/lib/Zend/Soap/Server.php(889): SoapServer->handle('<?xml version="...')
#6 /public_html/app/code/core/Mage/Api/Model/Server/Adapter/Soap.php(174): Zend_Soap_Server->handle()
#7 /public_html/app/code/core/Mage/Api/Model/Server.php(138): Mage_Api_Model_Server_Adapter_Soap->run()
#8 /public_html/app/code/core/Mage/Api/controllers/SoapController.php(40): Mage_Api_Model_Server->run()
#9 /public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Api_SoapController->indexAction()
#10 /public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('index')
#11 /public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#12 /public_html/app/code/core/Mage/Core/Model/App.php(365): Mage_Core_Controller_Varien_Front->dispatch()
#13 /public_html/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#14 /public_html/index.php(83): Mage::run('', 'store')
#15 {main}

So I have went and done a diff between the Abstract.php from 1.9.2.4 and 1.9.3.0 and get the following:

290a291
>                 $result = array();
292c293
<                     return $model->$method((is_array($args) ? $args : array($args)));
---
>                     $result = $model->$method((is_array($args) ? $args : array($args)));
294c295
<                     return $model->$method($args);
---
>                     $result = $model->$method($args);
296c297
<                     return call_user_func_array(array(&$model, $method), $args);
---
>                     $result = call_user_func_array(array(&$model, $method), $args);
297a299
>                 return $this->processingMethodResult($result);
403a406
>                     $callResult = array();
405c408
<                         $result[] = $model->$method((is_array($args) ? $args : array($args)));
---
>                         $callResult = $model->$method((is_array($args) ? $args : array($args)));
407c410
<                         $result[] = $model->$method($args);
---
>                         $callResult = $model->$method($args);
409c412
<                         $result[] = call_user_func_array(array(&$model, $method), $args);
---
>                         $callResult = call_user_func_array(array(&$model, $method), $args);
410a414
>                     $result[] = $this->processingMethodResult($callResult);
544a549,585
>     }
> 
>     /**
>      * Prepare Api data for XML exporting
>      * See allowed characters in XML:
>      * @link http://www.w3.org/TR/2000/REC-xml-20001006#NT-Char
>      *
>      * @param array $result
>      * @return mixed
>      */
>     public function processingMethodResult(array $result)
>     {
>         foreach ($result as &$row) {
>             if (!is_null($row) && !is_bool($row) && !is_numeric($row)) {
>                 $row = $this->processingRow($row);
>             }
>         }
>         return $result;
>     }
> 
>     /**
>      * Prepare Api row data for XML exporting
>      * Convert not allowed symbol to numeric character reference
>      *
>      * @param $row
>      * @return mixed
>      */
>     public function processingRow($row)
>     {
>         $row = preg_replace_callback(
>             '/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}\x{10000}-\x{10FFFF}]/u',
>             function ($matches) {
>                 return '&#' . Mage::helper('core/string')->uniOrd($matches[0]) . ';';
>             },
>             $row
>         );
>         return $row;

Any help would be appreciated.

Was it helpful?

Solution

Same error with another extension here. system.log says

Argument 1 passed to Mage_Api_Model_Server_Handler_Abstract::processingMethodResult() must be of the type array, string given, called in app/code/core/Mage/Api/Model/Server/Handler/Abstract.php...

I think the problem is the new method

Mage_Api_Model_Server_Handler_Abstract::processingMethodResult(array $result)

which only accepts arrays. So every Api function returning a scalar value will throw this error. To get this going again i copied app/code/core/Mage/Api/Model/Server/Handler/Abstract.php to app/code/local/Mage/Api/Model/Server/Handler/Abstract.php and patched processingMethodResult:

public function processingMethodResult($result)
{
    if (is_array($result)) {
        foreach ($result as &$row) {
            if (!is_null($row) && !is_bool($row) && !is_numeric($row)) {
                if (is_array($row)) {
                    $row = $this->processingMethodResult($row);
                } else {
                    $row = $this->processingRow($row);
                }
            }
        }
    } else {
        if (!is_null($result) && !is_bool($result) && !is_numeric($result)) {
            $result = $this->processingRow($result);
        }
    }
    return $result;
}

OTHER TIPS

More than likely the ShipStation module and/or the PHP version you are running isn't compatible:

Guessing off the truncated PHP error message that's returned:

Argument 1 pass...' is most likely Argument 1 passed to methodhere() must be an instance of string, string given

What version of PHP are you running and have you consulted with ShipStation to see if they have any newer version and/or compatibility issues with the latest Magento version/patches.

Also, you can add a bit more logging here: https://github.com/OpenMage/magento-mirror/blob/magento-1.9/lib/Zend/Soap/Server.php#L889 to capture more of the truncated PHP error that's being returned, to get validation that it is the correct error being returned.

Hope this helps.

Belgors answer really helped me, but I ended up modifying the patch slightly to allow for extra objects to be included in the API reposnse.

For example you now get aheadWorks storecredit and/or giftcard object-arrays with the Magento XML-RPC call for order information.

(code updated from suggestion by Björn Tantau - to better work with objects & collections)

public function processingMethodResult($result)
{
    if (is_object($result) && is_callable(array($result, 'toArray'))) {
        $result = $result->toArray();
    }
    if (is_array($result)) {
        foreach ($result as &$row) {
            if (is_object($row) && is_callable(array($row, 'toArray'))) {
                $row = $row->toArray();
            }
            if (!is_null($row) && !is_bool($row) && !is_numeric($row)) {
                if (is_array($row)) {
                    $row = $this->processingMethodResult($row);
                } else {
                    $row = $this->processingRow($row);
                }
            }
        }
    } else {
        if (!is_null($result) && !is_bool($result) && !is_numeric($result)) {
            $result = $this->processingRow($result);
        }
    }
    return $result;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top