Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
849 views
in Technique[技术] by (71.8m points)

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

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

Here is my 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>

GET LAST RESPONSE :

REQUEST HEADERS:

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

Here is the response.

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:localhostwwwest5index.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:localhostwwwest5index.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" 
} 

GET LAST RESPONSE :

REQUEST HEADERS:

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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

PHP's native SOAP extension is an undebuggable binary blob of horrors.

According to this comment in the PHP manual, it is hard-coded to send SOAP requests with the MIME content type application/soap+xml.

Your SOAP server seems to reject this content type, expecting only text/xml.

According to this SOAP 1.2 standard document, section 7.1.4 on SOAP over HTTP:

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.

The SOAP server you are using is not complaint with the 1.2 standard.

(For the record, this is the first time I've ever, ever seen anyone with a question about the PHP SOAP extension where the problem wasn't with the extension itself!)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...