C#中的Magento API - 抛出内容类型异常

时间:2013-06-04 07:37:31

标签: c# .net

当我尝试在我的C#应用​​程序中使用Magento产品下载webservice调用时。 我收到一些内容类型Mismatch错误。你能帮我吗?

这是我的代码:

 using (Mage_Api_Model_Server_V2_HandlerPortTypeClient proxy = new Mage_Api_Model_Server_V2_HandlerPortTypeClient())
            {
                string sessionId = proxy.login("stalin", "12345678");
                customerCustomerEntity[] customers = proxy.customerCustomerList(sessionId, new filters());
                foreach (customerCustomerEntity customer in customers)
                {
                    Console.WriteLine(String.Format("{0}. {1} {2}", customer.customer_id, customer.firstname, customer.lastname));
                }
                proxy.endSession(sessionId);
            }

以下是我的网络配置详情:

  <system.serviceModel>
<bindings>
  <basicHttpBinding>
    <binding name="Mage_Api_Model_Server_V2_HandlerBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="9999999" maxBufferPoolSize="524288" maxReceivedMessageSize="9999999" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
      <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
        <message clientCredentialType="UserName" algorithmSuite="Default"/>
      </security>
    </binding>
  </basicHttpBinding>
</bindings>
<client>
  <endpoint address="http://<my server ip>/magento-1.7.0.2/index.php/api/v2_soap/index/" binding="basicHttpBinding" bindingConfiguration="Mage_Api_Model_Server_V2_HandlerBinding" contract="VPMagento.Mage_Api_Model_Server_V2_HandlerPortType" name="Mage_Api_Model_Server_V2_HandlerPort"/>
</client>

错误信息是:

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>'.

请问这个问题的解决方案吗? 否则,请告诉我如何在C#中使用Magento API。

0 个答案:

没有答案