NuSOAP - 如何将 HTTP 协议设置为 1.1?

NuSOAP - How to set HTTP protocol to 1.1?

我已经研究了很长时间,但没有找到关于如何实现它的参考资料。目前我在服务器上使用了三四次操作,但最后一次失败给出了无意义的错误(“”)。

在一些测试工具中逆向发现HTTP版本不一样...有了下面的情况,如何将HTTP协议设置为1.1版本?

PHP

require_once('lib/nusoap.php');
$proxyhost = isset($_POST['proxyhost']) ? $_POST['proxyhost'] : '';
$proxyport = isset($_POST['proxyport']) ? $_POST['proxyport'] : '';
$proxyusername = isset($_POST['proxyusername']) ? $_POST['proxyusername'] : '';
$proxypassword = isset($_POST['proxypassword']) ? $_POST['proxypassword'] : '';
$client = new nusoap_client(
'http://www.quadranet.co.uk/qslwebservice/qslwebbooking.asmx?wsdl',
'wsdl',
$proxyhost,
$proxyport,
$proxyusername,
$proxypassword
);
$err = $client->getError();
if ($err) {
echo '<h2>Constructor error</h2><pre>'.$err.'</pre>';
}
$result = $client->call(
'BookTable',
'<request recordversion="5.0.0"><parameters locationprefix="'.$_POST['tb_w_locationprefix'].'" atdate="'.$_POST['tb_w_atdate'].'" attime="'.$_POST['tb_w_attime'].'" session="'.$_POST['tb_w_session'].'" covers="'.$_POST['tb_w_covers'].'" surname="'.$_POST['tb_w_surname'].'" title="'.$_POST['tb_w_title'].'" telephone="'.$_POST['tb_w_telephone'].'" productid="'.$_POST['tb_w_productid'].'" sourcesite="'.$_POST['tb_w_sourcesite'].'" authcode="'.$_POST['tb_w_authcode'].'" email="'.$_POST['tb_w_email'].'" forename="'.$_POST['tb_w_forename'].'" message="'.$_POST['tb_w_message'].'" /></request>'
);

SOAP 请求(注意它是 HTTP/1.0)

POST /qslwebservice/qslwebbooking.asmx HTTP/1.0
Host: www.quadranet.co.uk
User-Agent: NuSOAP/0.9.5 (1.123)
Content-Type: text/xml; charset=UTF-8
SOAPAction: "http://www.resv5.com/webservices/BookTable"
Content-Length: 674
<?xml version="1.0" encoding="UTF-8">
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:ns5636="http://tempuri.org">
<SOAP-ENV:Body>
<request recordversion="5.0.0">
<parameters locationprefix="BIS" atdate="2015-07-25" attime="20:30" session="2" covers="3" surname="Tester" title="Dr." telephone="+440123456789" productid="1" sourcesite="Test" authcode="3FD1B17E" email="name@email.com" forename="Manu" message="comments" />
</request>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

快速查看源代码,有两个函数将 HTTP 协议版本设置为 1.1。

function usePersistentConnection(){
    if (isset($this->outgoing_headers['Accept-Encoding'])) {
        return false;
    }
    $this->protocol_version = '1.1';
    $this->persistentConnection = true;
    $this->setHeader('Connection', 'Keep-Alive');
    return true;
}

function setEncoding($enc='gzip, deflate') {
    if (function_exists('gzdeflate')) {
        $this->protocol_version = '1.1';
        $this->setHeader('Accept-Encoding', $enc);
        if (!isset($this->outgoing_headers['Connection'])) {
            $this->setHeader('Connection', 'close');
            $this->persistentConnection = false;
        }
        // deprecated as of PHP 5.3.0
        //set_magic_quotes_runtime(0);
        $this->encoding = $enc;
    }
}

因此您必须执行以下操作

$client = new nusoap_client('http://www.quadranet.co.uk/qslwebservice/qslwebbooking.asmx?wsdl', 'wsdl', $proxyhost, $proxyport, $proxyusername, $proxypassword);
$client->useHTTPPersistentConnection();

很好,usePersistentConnection() 不是 nusoap_client class 的方法,但我发现 useHTTPPersistentConnection() 将 HTTP 设置为 1.1。

但这并没有解决我的问题,我仍然收到错误消息的响应,其中的参数从未发送过:S

我想是另一个问题的材料。谢谢!