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类的方法,但我发现useHTTPPersistentConnection()将HTTP设置为1.1。

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

我想这是另一个问题。谢谢!