C# SOAP - 反序列化回复消息正文时出错(Magento API) [英] C# SOAP - Error in deserializing body of reply message (Magento API)

查看:45
本文介绍了C# SOAP - 反序列化回复消息正文时出错(Magento API)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下代码将 C# 应用程序连接到 Magento 1.6(通过 Magento SOAP V2):

I'm trying to connect a C# app to Magento 1.6 (through Magento SOAP V2) using the following code:

using (Mage_Api_Model_Server_Wsi_HandlerPortTypeClient proxy = new Mage_Api_Model_Server_Wsi_HandlerPortTypeClient())
{
  string sessionId = proxy.login("XXXXXXX", "XXXXXXXXXXX");
  Console.WriteLine(sessionId);
}

我收到以下错误:

Error in deserializing body of reply message for operation 'login'.

我使用 Fiddler 检查传输,结果如下:

I used Fiddler to inspect the transfer and this is the result:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:Magento">
<SOAP-ENV:Body>
<ns1:loginResponseParam>
<result>fc094df96480dbbcdXXXXXXXXXXXXXXX</result>
</ns1:loginResponseParam>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

我正在使用:

有什么想法可以解决(或调试)这个问题吗?

Any ideas how I can fix (or debug) this problem?

推荐答案

这实际上很容易解决.打开用于连接到 magento 的应用程序的 web.config/app.config

this is actually pretty easy to fix. Open the web.config/app.config for the application you are using to connect to magento

找到这一行

<client>
      <endpoint address="http://YourWeb.com/index.php/api/v2_soap/index/" binding="basicHttpBinding" bindingConfiguration="BasicBinding" contract="Webstore.Mage_Api_Model_Server_Wsi_HandlerPortType" name="Mage_Api_Model_Server_Wsi_HandlerPort" />
</client>

记下绑定配置和绑定类型.在上面的basicHttpBinding/BasicBinding

Make note of the binding configuration and binding type. In the above basicHttpBinding/BasicBinding

接下来找到以下配置部分.

Next locate the following config section.

<bindings>
  <basicHttpBinding>
      <binding name="BasicBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="999999" maxBufferPoolSize="999999" maxReceivedMessageSize="999999" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
          <readerQuotas maxDepth="999999" maxStringContentLength="999999" maxArrayLength="999999" maxBytesPerRead="999999" maxNameTableCharCount="999999" />
          <security mode="None" />
      </binding>
  </basicHttpBinding>
</bindings>

注意这里的嵌套,绑定 -> 绑定类型 -> 按名称绑定元素

Notice the nesting here, binding -> binding type -> binding element by name

当 Visual Studio 生成代理时,它为读者配额提供的默认值不足以容纳所有数据.就像我在上面的例子中所做的那样,简单地增加它们.

When visual studio generates the proxy the default values that it gives for the reader quota and such are not large enough to hold all of the data. Simply increase them all like I have done in the above example.

这篇关于C# SOAP - 反序列化回复消息正文时出错(Magento API)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆