内容类型'text/xml; charset = utf-8'不是预期的类型'application/soap + xml; charset = utf-8' [英] content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8'

查看:394
本文介绍了内容类型'text/xml; charset = utf-8'不是预期的类型'application/soap + xml; charset = utf-8'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I've been trying for a long time to send right request to soap server. I'm keep getting error message.

这是我的xml

获取最后一个请求(添加了换行符):

GET LAST REQUEST (newlines added):

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

这篇关于内容类型'text/xml; charset = utf-8'不是预期的类型'application/soap + xml; charset = utf-8'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆