【问题标题】:C#+Magento API V2:The content type text/xml; charset=utf-8,text/xml; charset=UTF-8 of the response message does not matchC#+Magento API V2:内容类型text/xml;字符集=utf-8,文本/xml; charset=UTF-8 的响应消息不匹配
【发布时间】:2014-01-02 17:15:04
【问题描述】:

我正在开发一个项目以使用 C#[MVC4.5] 从 Magento 网站[V1.5.1] 下载订单列表, 在我开始之前,我从 www 服务器构建了一个开发服务器复制完整文件,并且我的程序在开发服务器上运行得很好。之后,我将 web 服务引用 [http://dev.example.com/index.php/api/v2_soap/?wsdl] 更改为 [http://www.example.com/index.php/api/v2_soap/?wsdl],then 我收到如下错误消息:

“/”应用程序中的服务器错误。

内容类型text/xml;字符集=utf-8,文本/xml;字符集=UTF-8 的 响应消息与绑定的内容类型不匹配 (文本/xml;字符集=utf-8)。如果使用自定义编码器,请确保 IsContentTypeSupported 方法已正确实现。第一个 566 响应的字节数为:《?xml version="1.0" encoding="UTF-8"?》 《SOAP-ENV:信封 xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:Magento" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"》《SOAP-ENV:Body》《ns1:startSessionResponse》《startSessionReturn xsi:type="xsd:string"》fe4d182c95add56efba2191ed9d4dddb《/startSessionReturn>《/ns1:startSessionResponse>《/SOAP-ENV:Body》《/SOAP-ENV:Envelope》

这是响应头信息:

WWW Server
HTTP/1.1 500 Internal Server Error
Cache-Control: private
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/8.0
X-AspNet-Version: 4.0.30319
X-SourceFiles: =?UTF-8?B?RTpcTkVUNC41XFByb2R1Y2VNYW5hZ2VtZW50XFByb2R1Y2VNYW5hZ2VtZW50?=
X-Powered-By: ASP.NET
Date: Mon, 16 Dec 2013 17:09:20 GMT
Content-Length: 17079


Develop Server:
HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/html; charset=utf-8
Content-Encoding: gzip
Vary: Accept-Encoding
Server: Microsoft-IIS/8.0## Heading ##
Set-Cookie: .ASPXAUTH=********; path=/; HttpOnly
X-AspNetMvc-Version: 4.0
X-AspNet-Version: 4.0.30319
X-SourceFiles: =?UTF-8?B?RTpcTkVUNC41XFByb2R1Y2VNYW5hZ2VtZW50XFByb2R1Y2VNYW5hZ2VtZW50?=
X-Powered-By: ASP.NET
Date: Mon, 16 Dec 2013 17:29:36 GMT
Content-Length: 3789

By the way,i tried to change php file Soap.php:
->setHeader('Content-Type','text/xml; charset='.$apiConfigCharset, true);
 but didn't work for me .....

如果有人能提供帮助,我非常感激,谢谢......

【问题讨论】:

标签: magento soap


【解决方案1】:

在 Magento 堆栈中出现了类似的问题。我在那里回答了,见:https://magento.stackexchange.com/questions/42536/problems-calling-magento-soap-v2-service-in-c/43046#43046

【讨论】:

    【解决方案2】:

    使用 XML rpc API。它被称为ez时事通讯。您需要创建一个 API 用户,访问权限为http://jmawebtechnologies.com/support/quickbooks/magento-cloud-cart-connector-installation

    【讨论】:

    • 尝试升级到最新版本的 Magento。我有 1.702 或更高版本的客户端,它运行良好。我知道以前版本的 Magento 在其 API 中有编码错误。
    • 感谢 Joseph,但项目快完成了,所以我无法更改为“XML RPC API”。
    • 实际上,记录这个结果xml,我以为他们已经返回了“SessionID”,我只是不知道“HTTPS”和“HTTP”有什么区别......
    • 你有没有找到解决这个问题的方法?现在遇到了完全相同的问题。
    猜你喜欢
    • 1970-01-01
    • 2023-03-30
    • 2011-07-12
    • 2015-03-02
    • 1970-01-01
    • 2012-01-28
    • 1970-01-01
    • 1970-01-01
    • 2020-04-25
    相关资源
    最近更新 更多