繁体   English   中英

由于内容类型为'text / xml ;,因此无法处理该消息; charset = utf-8'不是预期的类型'application / soap + xml; charset = utf-8'

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

实现以下代码后,我收到“由于内容类型'text / xml; charset = utf-8'不是预期的类型'application / soap + xml; charset = utf-8'而无法处理消息”。 请协助调查问题。

我使用SOAP UI及其成功尝试了相同的服务。 将SOAP版本更改为1.1后,我也通过SOAP UI收到相同的消息。

样例代码

<?php
    $context = stream_context_create([
        'ssl' => [
            'soap_version' => SOAP_1_2,
            'verify_peer' => false,
            'verify_peer_name' => false,
            'connection_timeout' => 1
            ]
    ]);

       $requestParams = '<?xml version="1.0" encoding="UTF-8"?>
        <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
        <s:Header>
            <CustomHeader xmlns="http://schemas.test.com/CustomHeader">

            </CustomHeader>
        </s:Header>
        <s:Body>

        </s:Body>
    </s:Envelope>';


        $client  = new SoapClient('https://myservice.svc?singlewsdl',  array('stream_context' => $context)); 
        $client->__setLocation('https://myservice.svc');
        $response = $client->__soapCall('mymethod', array($requestParams));
    ?>

我认为您不能在SSL参数下设置soap版本。 尝试在初始化期间将soap版本设置为其他参数。

    $client  = new SoapClient('https://myservice.svc?singlewsdl',  array('soap_version' => SOAP_1_2,'stream_context' => $context)); 

暂无
暂无

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

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