【问题标题】:Why do I get Error Response not of type text/xml: text/html?为什么我得到不是 text/xml 类型的错误响应:text/html?
【发布时间】:2012-07-15 19:46:51
【问题描述】:

我是使用 SOAP 与 Web 服务通信的新手,我最近在 php 中编写了一个客户端来与 Web 服务通信,但收到此错误消息:

“错误响应不是 text/xml 类型:text/html”

我发送的格式有问题吗?请找到 下面的请求:

Request

POST /MobileCashPayout.asmx HTTP/1.0
Host: www.mtn.com
User-Agent: NuSOAP/0.9.5 (1.123)
Content-Type: text/xml; charset=ISO-8859-1
SOAPAction: ""
Content-Length: 971

<?xml version="1.0" encoding="ISO-8859-1"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 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:Body><ns5667:Payout xmlns:ns5667="http://tempuri.org"><__numeric_0 xsi:type="xsd:string">testmerc</__numeric_0><__numeric_1 xsi:type="xsd:string">testmerc</__numeric_1><__numeric_2 xsi:type="xsd:string">256750000005</__numeric_2><__numeric_3 xsi:type="xsd:string">256753986532</__numeric_3><__numeric_4 xsi:type="xsd:string">256750000005</__numeric_4><__numeric_5 xsi:type="xsd:string">100.00</__numeric_5><__numeric_6 xsi:type="xsd:string">2222</__numeric_6><__numeric_7 xsi:type="xsd:string"></__numeric_7><__numeric_8 xsi:type="xsd:string">BETNET</__numeric_8></ns5667:Payout></SOAP-ENV:Body></SOAP-ENV:Envelope>

【问题讨论】:

  • 您收到的回复似乎是html,而不是预期的xml。您可以尝试通过 Fiddler 发布您的请求,以便您可以检查实际响应,而不受代码的限制。
  • @Sir Crispalot 请告诉我更多关于 Fiddler 的信息?是浏览器插件吗?还是一个 php 库?
  • 这是一款允许您构建 HTTP 请求并查看原始响应的软件。它还充当代理,以便您可以通过它传递所有请求以动态检查它们。 fiddler2.com/fiddler2.

标签: php web-services nusoap


【解决方案1】:

您可能想尝试发送“Accept: text/xml”标头以通知服务器您正在等待 XML 响应。

【讨论】:

  • 我该怎么做?你能示范一下吗?
  • 所以我看到您正在使用 NuSOAP。看看这个 StackOverflow 项目stackoverflow.com/questions/945922/… 这里有一个答案暗示您使用的 SOAP 协议版本可能是问题,建议在实例化时传递配置参数以使用 SOAP 协议 1.1 作为最现代的 SOAP 服务器客户端期望使用 application/soap+xml 的内容类型。您可以尝试使用原生 PHP SOAP 实现以获得更好的结果。
  • 我的客户似乎只需要 text/xml 的内容类型,而不是 text/html 或 applicatoin/soap+xml 的内容类型。因此,不幸的是,接受 application/soap+xml 的建议似乎没有用......欢迎任何其他建议
猜你喜欢
  • 2015-04-19
  • 1970-01-01
  • 1970-01-01
  • 2014-03-11
  • 2020-10-01
  • 1970-01-01
  • 2018-12-13
  • 2015-03-03
  • 1970-01-01
相关资源
最近更新 更多