实现以下代码后,我收到“由于内容类型'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));
?>
答案 0 :(得分:0)
我认为您不能在SSL参数下设置肥皂版本。 尝试在初始化过程中将soap版本设置为其他参数。
$client = new SoapClient('https://myservice.svc?singlewsdl', array('soap_version' => SOAP_1_2,'stream_context' => $context));