繁体   English   中英

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

[英]content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8'

我一直在努力向肥皂服务器发送正确的请求。 我一直在收到错误消息。

这是我的xml

得到最后的请求(添加换行符):

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

得到最后的回应:

请求标题:

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" 
} 

得到最后的回应:

请求标题:

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

这似乎已经为我修好了。

$client = new SoapClient($this->url, array('soap_version' => SOAP_1_2));

PHP的本机SOAP扩展是一个不可摧毁的二进制blob。

根据PHP手册中的这条评论,硬编码使用MIME内容类型application/soap+xml发送SOAP请求。

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

根据SOAP 1.2标准文档 ,关于SOAP over HTTP的7.1.4节:

符合此绑定的实现:

  1. 必须能够发送和接收使用媒体类型“application / soap + xml”序列化的消息,其正确的用途和参数在A中描述.application / soap + xml媒体类型

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

(为了记录,这是我第一次见过有关PHP SOAP扩展的问题的人,问题在于扩展本身!)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM