NuSOAP 0.9.5

2010-04-26
2013-06-06
  • Scott Nichol
    Scott Nichol
    2010-04-26

    NuSOAP 0.9.5 is available with improvements for PHP 5.3.x and .NET interoperability.

     
  • Hi, I don t know where to post that I think here might be appropriate. I think I found a bug in the NUSoap Library when using a proxy. Actually the fsocket open use the NUSoap port instead of the proxy port.
    Here is the original code :

    function connect($connection_timeout=0,$response_timeout=30){
              //Code here ...
          if ($this->io_method() == 'socket') {
            if (!is_array($this->proxy)) {
                $host = $this->host;
                $port = $this->port;
            } else {
                $host = $this->proxy['host'];
                $port = $this->proxy['port'];
            }
    
            // use persistent connection
            if($this->persistentConnection && isset($this->fp) && is_resource($this->fp)){
                if (!feof($this->fp)) {
                    $this->debug('Re-use persistent connection');
                    return true;
                }
                fclose($this->fp);
                $this->debug('Closed persistent connection at EOF');
            }
            // munge host if using OpenSSL
            if ($this->scheme == 'ssl') {
                $host = 'ssl://' . $host;
            }
            $this->debug('calling fsockopen with host ' . $host . ':'.$port.' connection_timeout ' . $connection_timeout);
            // open socket
    //HERE IS THE PROBLEM
    //the local variable port is not use. So if proxy settings are set the proxy port is not used.
            if($connection_timeout > 0){
                $this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str, $connection_timeout);
            } else {
                $this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str);
            }
    

    Here is what I ve changed to ensure a connection :

    function connect($connection_timeout=0,$response_timeout=30){
              //Code here ...
          if ($this->io_method() == 'socket') {
            if (!is_array($this->proxy)) {
                $host = $this->host;
                $port = $this->port;
            } else {
                $host = $this->proxy['host'];
    //HERE Always have a port either the proxy one if specified or the default soap client one.
                $port = (!empty($this->proxy['port'])) ? $this->proxy['port'] :$this->port ;
            }
    
            // use persistent connection
            if($this->persistentConnection && isset($this->fp) && is_resource($this->fp)){
                if (!feof($this->fp)) {
                    $this->debug('Re-use persistent connection');
                    return true;
                }
                fclose($this->fp);
                $this->debug('Closed persistent connection at EOF');
            }
            // munge host if using OpenSSL
            if ($this->scheme == 'ssl') {
                $host = 'ssl://' . $host;
            }
            $this->debug('calling fsockopen with host ' . $host . ':'.$port.' connection_timeout ' . $connection_timeout);
            // open socket
    //HERE
            if($connection_timeout > 0){
                $this->fp = @fsockopen( $host, $port, $this->errno, $this->error_str, $connection_timeout);
            } else {
                $this->fp = @fsockopen( $host, $port, $this->errno, $this->error_str);
            }
    

    Hope it will help. Is there any other place to specify bugs ? If so let me know and sorry for posting here again

    Vincent