简体   繁体   English

具有C#的Magento SOAP API V2:需要HTTP身份验证的商店出现问题

[英]Magento SOAP API V2 with C#: Issue with Stores that Require HTTP Authentication

REVISED QUESTION 修订的问题
I have revised the original question (as seen below) so that I can mark a part of the problem as answered. 我已经修改了原始问题(如下所示),以便可以将部分问题标记为已回答。 So here goes: 因此,这里去:
I have built a tool to import sales orders from customer stores (magento) for integration into our legacy order processing system. 我已经构建了一个工具,可以从客户商店(magento)导入销售订单,以集成到我们的旧订单处理系统中。 I have five stores to import from. 我有五家商店要进口。 One of them has HTTP Authentication set on its store and my API Login fails because of this. 其中一个在其存储上设置了HTTP身份验证,因此我的API登录失败。 How do I get past this? 我该如何克服?



ORIGINAL QUESTION (Title: Importing Sales Orders from Magento Using C#: There is an error in XML document (2, 372)): 原始问题(标题:使用C#从Magento导入销售订单:XML文档(2,372)中存在错误):

I have built a tool to import sales orders from customer stores (magento) for integration into our legacy order processing system. 我已经构建了一个工具,可以从客户商店(magento)导入销售订单,以集成到我们的旧订单处理系统中。 I have five stores to import from. 我有五家商店要进口。 Three work fine. 三个工作正常。

  • PROBLEM 1: The fourth store throws up this exception upon executing the salesOrderList() call: 问题1:第四家商店在执行salesOrderList()调用时抛出此异常:

    A first chance exception of type 'System.InvalidOperationException' occurred in System.Xml.dll System.Xml.dll中发生类型为'System.InvalidOperationException'的第一次机会异常

    There is an error in XML document (2, 372). XML文档(2,372)中有错误。

    The login succeeds, I am able to enumerate attribute values, etc. But I am unable to run the salesOrderList() function with any filter (and null too). 登录成功,我能够枚举属性值,等等。但是我无法使用任何过滤器(也为null )运行salesOrderList()函数。 It would be great if someone has experience with this and can point me in the right direction. 如果有人对此有经验并能指出正确的方向,那就太好了。

  • PROBLEM 2: The fifth store has HTTP authorization to access its main magento page. 问题2:第五家商店具有HTTP授权以访问其主要的magento页面。 I have only worked with API User Name and API Key. 我只使用过API用户名和API密钥。 But it looks like I have to cross the HTTP Authorization hurdle to get to the API login stage. 但是看来我必须克服HTTP授权障碍,才能进入API登录阶段。 The Login() function of magento web service takes only the API User Name and API Key. magento Web服务的Login()函数仅采用API用户名和API密钥。 Not sure how to handle the extra layer of HTTP Authentication. 不确定如何处理HTTP身份验证的额外层。 Can anyone help? 有人可以帮忙吗?

This will happen often, you just got lucky and it's the first time you're having this problem. 这种情况经常发生,您很幸运,这是您第一次遇到此问题。

What you can do is using fiddler verify why are you receiving a bad XML format, as .NET only parses it and sees that Magento did not sent anything that is worth of trying as it's wrongly created. 您所能做的就是使用提琴手验证为什么收到的XML格式错误,因为.NET仅对其进行解析,并发现Magento没有发送任何值得尝试的内容,因为它是错误创建的。

Normally you end up parsing the raw responses from Magento as it's way safer, or use XmlRpc calls. 通常,您最终会解析Magento的原始响应,因为它更安全,或者使用XmlRpc调用。

But for now, check as you have more than one to test, the difference between the responses in fiddler. 但是现在,请检查您是否有多个要测试的小提琴手的响应之间的差异。

Regarding your authentication, you need to ask the host for the credentials, and add them to your request as a new NetworkCredentials object in the correct property of your service object. 关于身份验证,您需要向主机询问凭据,并将其作为新的NetworkCredentials对象添加到您的请求中,该对象是服务对象的正确属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM