1

这是我第一次尝试使用 Magento api。我正在尝试使用 C#.NET 连接到我的 Magento 商店。我正在使用 .NET Framework 3.5。使用 AddServiceReference 我在下面添加了链接。

http://www.MyServer.com/index.php/api/v2_soap?wsdl=1

我还在系统 -> 配置 -> Magento Core API 中将WS-I 兼容性设置为“是”。

但是当我在我的页面中引用服务时,我无法生成服务的对象。我正在寻找要连接的“Mage_Api_Model_Server_Wsi_HandlerPortType”对象。

我的 Magento 服务。

(当在 MyMagentoService 之后按 . 时,我没有得到任何对象。我不知道为什么。)

当我将 System -> Configuration -> Magento Core API -> WS-I compatible 设置为 NO 时,我能够获得如下对象。

MagentoService.Mage_Api_Model_Server_V2_HandlerPortTypeClient ctx = new         Mage_Api_Model_Server_V2_HandlerPortTypeClient(); 
string sessionID = ctx.login("Username", “Password");

但随后 ctx.login 抛出错误

The content type text/html of the response message does not match the content type of the binding (text/xml; charset=utf-8). 
If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. 
The first 361 bytes of the response were: ‘<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> 

<SOAP-ENV:Body> 

<SOAP-ENV:Fault> 

<faultcode>0</faultcode> 

<faultstring>SOAP extension is not loaded.</faultstring> 

</SOAP-ENV:Fault> 

</SOAP-ENV:Body> 

</SOAP-ENV:Envelope>'

对于这个错误,当我用谷歌搜索时,我得到了答案,因为我需要将 WS-I 兼容性设置为“YES”。我不知道该怎么办。:(

4

1 回答 1

2

我遇到了同样的问题并解决了安装 PHP SOAP 扩展的问题。

浏览至此页面:{YOUR_MAGENTO_SHOP_URL}/api/v2_soap

它应该给你一个 XML 文档,解释更多关于 SOAP 的使用。如果您看到消息“0 无法在服务器上加载 Soap 扩展”或“0 SOAP 扩展未加载”,则 Web 服务器缺少 SOAP 支持。

更多信息在这里:https ://storeya.zendesk.com/entries/20405542-Api-Error-0-SOAP-extension-is-not-loaded

于 2013-12-19T13:58:51.317 回答