gpt4 book ai didi

php - 内容类型 'text/xml; charset=utf-8' 不是预期的类型 'application/soap+xml; charset=utf-8'

转载 作者:可可西里 更新时间:2023-11-01 13:02:48 25 4
gpt4 key购买 nike

我一直在尝试向 soap 服务器发送正确的请求。我不断收到错误消息。

这是我的xml

GET LAST REQUEST(添加换行符):

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/">
<SOAP-ENV:Body><ns1:TestData1><ns1:iVal>1</ns1:iVal></ns1:TestData1></SOAP-ENV:Body>
</SOAP-ENV:Envelope>

获取最后的回复:

请求 header :

POST /DPWebService/CardsService.svc/ICardsService HTTP/1.1
Host: d67v7tg1
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.2.9-1
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://tempuri.org/ICardsService/TestData1"
Content-Length: 254

这是回应。

object(SoapFault)#2 (8) { 
["message:protected"]=> string(142) "Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8'."
["string:private"]=> string(0) ""
["code:protected"]=> int(0)
["file:protected"]=> string(32) "C:\localhost\www\test5\index.php"
["line:protected"]=> int(208)
["trace:private"]=> array(3) {
[0]=> array(4) {
["function"]=> string(11) "__doRequest"
["class"]=> string(10) "SoapClient"
["type"]=> string(2) "->"
["args"]=> array(5) {
[0]=> string(254) " 1 "
[1]=> string(59) "http://d67v7tg1/DPWebService/CardsService.svc/ICardsService"
[2]=> string(42) "http://tempuri.org/ICardsService/TestData1"
[3]=> int(1)
[4]=> int(0)
}
}
[1]=> array(4) {
["function"]=> string(6) "__call"
["class"]=> string(10) "SoapClient"
["type"]=> string(2) "->"
["args"]=> array(2) {
[0]=> string(9) "TestData1"
[1]=> array(1) {
[0]=> array(2) {
["iVal"]=> int(1)
["strVal"]=> string(5) "Proba"
}
}
}
}
[2]=> array(6) {
["file"]=> string(32) "C:\localhost\www\test5\index.php"
["line"]=> int(208)
["function"]=> string(9) "TestData1"
["class"]=> string(10) "SoapClient"
["type"]=> string(2) "->"
["args"]=> array(1) {
[0]=> array(2) {
["iVal"]=> int(1)
["strVal"]=> string(5) "Proba"
}
}
}
}
["faultstring"]=> string(142) "Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8'."
["faultcode"]=> string(4) "HTTP"
}

获取最后的回复:

请求 header :

POST /DPWebService/CardsService.svc/ICardsService HTTP/1.1
Host: d67v7tg1
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.2.9-1
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://tempuri.org/ICardsService/TestData1"
Content-Length: 254

最佳答案

PHP 的原生 SOAP 扩展是一个无法调试的恐怖二进制 blob。

According to this comment in the PHP manual , 它被硬编码为发送 MIME 内容类型 application/soap+xml 的 SOAP 请求。

您的 SOAP 服务器似乎拒绝此内容类型,只需要 text/xml

根据 this SOAP 1.2 standard document ,关于 SOAP over HTTP 的第 7.1.4 节:

Conforming implementations of this binding:

  1. MUST be capable of sending and receiving messages serialized using media type "application/soap+xml" whose proper use and parameters are described in A. The application/soap+xml Media Type.

您使用的 SOAP 服务器不符合 1.2 标准。

(郑重声明,这是我第一次看到任何人对 PHP SOAP 扩展有疑问,而问题与扩展本身有关!)

关于php - 内容类型 'text/xml; charset=utf-8' 不是预期的类型 'application/soap+xml; charset=utf-8',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5405874/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com