我的nusoap电话就是这样
require_once('lib/nusoap.php');
$headers = array( 'Content-Type: application/xml',
'Authorization: Bearer ZGMK' );
$client = new nusoap_client("http://test.wsdl?wsdl", array('soap_version' => SOAP_1_2,));
$client->setUseCURL(true);
$client->setCurlOption(CURLOPT_SSLVERSION, '6'); // TLS 1.2
$client->setCurlOption(CURLOPT_SSLCERT, 'C:\xampp\htdocs\test\test.pem'); // TLS 1.2
$client->setCurlOption(CURLOPT_SSLCERTPASSWD, 'pass');
$client->setCurlOption(CURLOPT_HTTPHEADER, $headers);
$client->soap_defencoding = 'UTF-8';
$result = $client->call("Terminate", array("type" => "Main"));
$error = $client->getError();
if ($error) {
echo "<h2>Constructor error</h2><pre>" . $error . "</pre>";
}
if ($client->fault) {
echo "<h2>Fault</h2><pre>";
print_r($result);
echo "</pre>";
} else {
$error = $client->getError();
if ($error) {
echo "<h2>Error</h2><pre>" . $error . "</pre>";
} else {
echo "<h2>Main</h2>";
echo $result;
}
}
// show soap request and response
echo "<h2>Request</h2>";
echo "<pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
echo "<h2>Response</h2>";
echo "<pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";
对我来说一切都很好,但是会引发这样的错误
HTTP Error: Unsupported HTTP response status 415 Unsupported Media Type (soapclient->response has contents of the response)
在我最初的Google搜索中,我发现它与SOAP版本或内容类型有关。所以我也放了一些代码来设置它们(上面有)。但仍然出现相同的错误。并且我的请求日志仅将内容类型显示为text/xml
。
Request
POST /endpoint HTTP/1.0
Host: domain:4046
User-Agent: NuSOAP/0.9.5 (1.123)
Content-Type: text/xml; charset=UTF-8
SOAPAction: "https://terminate"
Content-Length: 424
Response
HTTP/1.1 415 Unsupported Media Type
Content-Length: 0
Content-Type: application/octet-stream
Date: Thu, 14 Feb 2019 11:35:04 GMT
Set-Cookie: HTTS008_001=!OpEB2CQQrC0ndIOtQCYvmLkbG3BVmQACyOEYvjJ4Y4ez8YLdDu0Vy5H/6dTFAf3WFjp8gW/ATWV0pIKPAn14Ph8O6cmOy1LfRGgPaKVll2YQNQ==; path=/; Httponly; Secure
有人可以指出我在这里做错了吗?