当前位置: 首页 > 知识库问答 >
问题:

C#+Magento API V2:内容类型text/xml;charset=utf-8,文本/XML;响应消息的charset=UTF-8不匹配

淳于功
2023-03-14

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

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

内容类型text/xml;charset=utf-8,文本/XML;响应消息的charset=UTF-8与绑定的内容类型(text/xml;charset=UTF-8)不匹配。如果使用自定义编码器,请确保正确实现了IsContentTypeSupported方法。响应的前566个字节是:“?xml version=”1.0“encoding=”UTF-8“?”soap-env:envelope 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:

以下是响应头信息:

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

如果有人能帮忙,我很感激,谢谢....

共有1个答案

柳涵映
2023-03-14

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

 类似资料: