简体   繁体   中英

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

I am getting "Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8'" after implementing below code. Please help to investigate the issue.

I tried the same service with SOAP UI and its success. After changing the SOAP version to 1.1 I am getting the same message with SOAP UI too.

sample code

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

I Don't think you can set the soap version under the SSL parameters. Try setting the soap version as a different parameter during initialization.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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