Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/252.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Magento API v2 PHP错误_Php_Api_Magento_Soap - Fatal编程技术网

Magento API v2 PHP错误

Magento API v2 PHP错误,php,api,magento,soap,Php,Api,Magento,Soap,我试着用肥皂和C。Magento 1.4.2 http://localhost/api/v2_soap/?wsdl 在这里我可以看到方法catalogProductCreate 因此,我尝试联系: $proxy = new SoapClient('http://localhost/api/v2_soap/?wsdl'); $sessionId = $proxy->login('xxx', 'xxxxxx'); // user with full access $newProductD

我试着用肥皂和C。Magento 1.4.2

http://localhost/api/v2_soap/?wsdl
在这里我可以看到方法
catalogProductCreate

因此,我尝试联系:

$proxy = new SoapClient('http://localhost/api/v2_soap/?wsdl');

$sessionId = $proxy->login('xxx', 'xxxxxx'); // user with full access

$newProductData                     = new stdClass();
$newProductData->name               = 'Product Name';
$newProductData->description        = 'Description';
$newProductData->short_description  = 'Short Description';
$newProductData->websites           = array(138);
$newProductData->categories         = array(7,15);
$newProductData->status             = 1;
$newProductData->price              = 45;
$newProductData->tax_class_id       = 2;
$newProductData->weight             = 1;


$result = $proxy->catalogProductCreate(
    $sessionId,           // Soap Session
    'simple',           // Product Type
    4,                  // Attribute Set Id (Default)
    'product-sku',      // Product Sku
    $newProductData     // Product Data
);
但我收到了这个输出:

致命错误:未捕获的SoapFault异常:[4]资源路径不可调用


确保wsdl资源是正确的,但是当我没有将用户设置为角色下的正确权限时,我也遇到了这个问题。

(详细信息是Magento 1.6.x特定的,但是技术,如果不是详细信息,应该适用于其他版本)

我假设,根据您的代码示例,您正在使用PHP客户端代码测试方法的存在性,然后您可以将该方法应用于来自C#应用程序的调用

假设是这样的话,这意味着您了解PHP,因此您需要在MagentoSOAP服务器PHP级别上对此进行调试。产生该错误的唯一类文件是

app/code/core/Mage/Api/Model/Server/Handler/Abstract.php
将以下日志记录临时直接添加到该文件中,或者在

app/code/local/Mage/Api/Model/Server/Handler/Abstract.php
用于代码池覆盖

在该类文件中查找以下异常

throw new Mage_Api_Exception('resource_path_not_callable')
这就是导致Magento soap服务器响应该故障的原因。该文件中有四个位置发生这种情况。在每个日志调用之上添加日志调用

Mage::Log(sprintf('Line %s in file %s',__LINE__, __FILE__));
throw new Mage_Api_Exception('resource_path_not_callable');
这将让您知道是哪个故障导致了问题,您可以从中进一步调试和记录。有两个地方会发生这种情况(文件中总共有四个,一个用于常规调用,另一个用于多调用)

按照出现的顺序,在注释中列出可能的原因

//here magento is attempting to instantiate the "API Model" that will perform
//the work of your API call. Upon instantiation, it discovers that the model 
//doesn't inherit from Mage_Api_Model_Resource_Abstract, and bails.
//This is rare for a non-custom API call, but might be caused by a class rewrite
//gone amuck, or a very hacked system
try {
    $model = Mage::getModel($modelName);
    if ($model instanceof Mage_Api_Model_Resource_Abstract) {
        $model->setResourceConfig($resources->$resourceName);
    }
} catch (Exception $e) {
    Mage::Log(sprintf('Line %s in file %s',__LINE__, __FILE__));
    throw new Mage_Api_Exception('resource_path_not_callable');
}


//Here Magento's been able to instantiate the $model, and is checking if the method is
//callable.  If not, it bails.  Again, for a standard, stock API call this shouldn't
//be happening, but could be the result of a rewrite gone wrong, or someone hacking an
//api class to make the method non accesible, or someone hacking the method mapping in api.xml
if (is_callable(array(&$model, $method))) {
    if (isset($methodInfo->arguments) && ((string)$methodInfo->arguments) == 'array') {
        return $model->$method((is_array($args) ? $args : array($args)));
    } elseif (!is_array($args)) {
        return $model->$method($args);
    } else {
        return call_user_func_array(array(&$model, $method), $args);
    }
} else {
    Mage::Log(sprintf('Line %s in file %s',__LINE__, __FILE__));
    throw new Mage_Api_Exception('resource_path_not_callable');
}

找出Magento抛出API错误的原因。它通常会指向soap调用中的某个类型,或指向PHP系统中被黑客攻击的内容

将此文件放入magento/project的根文件夹中,以便您可以访问magento的所有方法


享受这个想法吧…

尝试创建一个具有角色的webservice用户,并将其分配给一个可以访问“ALL”的角色。“角色信息”中“角色资源”菜单中的选项。

您不完全理解错误的哪一部分?你能详细说明一下吗?在浏览器中打开它,看看是否有CatalogProductCreate这样的方法我知道这意味着我找不到该方法..但我可以在xml中看到它。。。如何解决这个问题?是的,我可以看到catalogProductCreate方法……这与C#?2011-12-16T10:39:12+00:00调试(7):文件/usr/www/app/code/core/Mage/Api/Model/Server/Handler/Abstract.phpLog get#class($Model)和$METHOD中的第295行有什么关系。也许你在这个模型中没有这样的方法,我这里也有同样的问题(第二个if)。我将模型和方法记录在方法的模型列表中,但显然不可调用。权限规则对所有人都适用。我在测试服务器上完成了它,它很有效。但是在我的prod服务器中,我得到了resource_path_not_callable异常。@DenisSpalenza然后添加一些调试代码,查看$model和$method中的内容,并找出PHP认为它们不可调用的原因。