Magento API v2 PHP 错误
我正在尝试将 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
$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] 资源路径不可调用。
I'm trying to use SOAP with C#. Magento 1.4.2.
http://localhost/api/v2_soap/?wsdl
Here I can see the method catalogProductCreate
So I try to connect with:
$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
);
But I receive this output:
Fatal error: Uncaught SoapFault exception: [4] Resource path is not callable.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
(详细信息是 Magento 1.6.x 特定的,但技术(如果不是详细信息)应该适用于其他版本)
我假设,根据您的代码示例,您正在使用 PHP 客户端代码来测试方法是否存在,然后您可以将其应用于 C# 应用程序的调用吗?
假设是这种情况,则意味着您了解 PHP,因此您需要在 Magento 肥皂服务器 PHP 级别进行调试。产生该错误的唯一类文件是
将以下日志记录临时直接添加到该文件,或者删除该类文件的副本
以进行代码池覆盖。
在该类文件中查找以下异常,
这就是导致 Magento 肥皂服务器响应该错误的原因。该文件中有四个地方发生这种情况。在每个调用上方添加日志记录调用。
这将使您知道哪个故障导致了您的问题,您可以从中进一步调试和记录。有两个地方可能会发生这种情况(文件中总共有四个地方,一个用于常规调用,另一个用于多重调用)。
按出现顺序排列,可能的原因在评论中。
找出 Magento 抛出 API 错误的原因。它通常会指向您的肥皂调用中的类型,或者指向您的 PHP 系统中被黑客攻击的内容
(details are Magento 1.6.x specific, but techniques, if not details, should be applicable to other versions)
I'm assuming, based on your code sample, that you're using PHP client code to test for the existence of a method, which you can then apply to a call from your C# application?
Assuming that's the case, it means you know PHP, so you'll want to debug this at the Magento soap server PHP level. The only class file that produces that fault is
Either add the following logging temporarily and directly to that file, or drop a copy of the class file in
for a codepool override.
Look in that class file for the following exception
This is what causes the Magento soap server to response with that fault. There are four places this happens in that file. Add logging calls above each one.
This will let you know which fault is causing your problem, from which you can debug and log further. There are two places this can happen (four total in the file, one for a regular call, another for the multi-call).
In order of appearance, with possible causes in the comments.
Figure out why Magento is throwing the API error. It will often point to a type in your soap call, OR point you towards what's been hacked in your PHP system
确保您可以使用 wsdl 资源是正确的,但是当我没有在角色下为用户设置正确的权限时,我也遇到了这个问题。
Making sure that you can she the wsdl resource is correct, but i also ran into that issue when i didnt have the user set up to the correct permissions under the role.
尝试创建一个具有角色的 Web 服务用户,并将其分配给有权访问“ALL”的角色。角色信息中角色资源菜单中的选项。
Try to create a webservice user with role and assigned them to a role that has access to ‘ALL’. option in role resources menu in role information.
将此文件放入magento/project的根文件夹中,以便您可以访问magento的所有方法。
享受这个想法...
Put this file into root folder of magento/project so that you can access all the method of magento.
Enjoy the idea...