douzhan1935 2019-02-14 11:36
浏览 66

不支持的HTTP响应状态415 nusoap调用。 无法设置SOAP请求的内容类型

My nusoap call is like this

  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>";

All looks good to me but it throws an error like this

HTTP Error: Unsupported HTTP response status 415 Unsupported Media Type (soapclient->response has contents of the response)

On my initial google search, I found it is related to SOAP version or content type. so I put some code to set them too (available above). but still, I am getting the same error. and my request log shows the content type as text/xml only.

    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

Can anyone point out what I am doing wrong here?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 【提问】基于Invest的水源涵养
    • ¥20 微信网友居然可以通过vx号找到我绑的手机号
    • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
    • ¥15 解riccati方程组
    • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
    • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
    • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
    • ¥50 树莓派安卓APK系统签名
    • ¥65 汇编语言除法溢出问题
    • ¥15 Visual Studio问题