我需要将内容类型从“text/xml;charset=utf-8”更改为“application/soap+xml;charset=utf-8”。
我正在使用 PHP 中默认存在的 SoapClient 类将请求从 PHP 发送到另一台服务器(Oracle 服务器)。我正在使用 PHP v7.0.10。
根据 SoapClient 文档,我应该将 options 数组中的 soap_version 设置为 SOAP_1_2,它会更改内容类型,但它不会这样做。
SOAP 请求
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:pub="http://xmlns.oracle.com/oxp/service/PublicReportService">
<soap:Header/>
<soap:Body>
<pub:runReport>
<pub:reportRequest>
<pub:reportAbsolutePath>/Human Capital Management/Workforce Management/Human Resources Dashboard/Fusion User Information.xdo</pub:reportAbsolutePath>
<pub:sizeOfDataChunkDownload>-1</pub:sizeOfDataChunkDownload>
</pub:reportRequest>
</pub:runReport>
</soap:Body>
</soap:Envelope>
Run Code Online (Sandbox Code Playgroud)
PHP代码
$WSDL = "https://example.com/xmlpserver/services/ExternalReportWSSService?WSDL";
$soap_options = array(
'uri' => 'http://www.w3.org/2003/05/soap-envelope',
'style' => SOAP_RPC,
'use' => SOAP_ENCODED,
'soap_version' => SOAP_1_2,
'cache_wsdl' => WSDL_CACHE_NONE,
'connection_timeout' => 30,
'trace' => true,
'encoding' => 'UTF-8',
// 'exceptions' => true,
'location' => $WSDL,
'login' …Run Code Online (Sandbox Code Playgroud)