Problem with PHP 5.2.x

Help
Marek W.
2013-03-14
2013-06-06
  • Marek W.
    Marek W.
    2013-03-14

    Good morning!
    I started using nusoap and write simple ws returning pdf files, my application runs on PHP v. 5.1.6 and 5.3.x Ok. The only proble is v. 5.2.5 - when I return string >512 B the response is wrong. What is going on?
    Example:
    =========
    $server->register(\'ws_Slownik\',   array(\'s\' => \'xsd:string\', \'r\' => \'xsd:string\'),   array(\'slownik\' => \'xsd:string\'), $ns, \"$ns#Slownik\",  \'rpc\',  \'encoded\',    \'Pobiera zawartosc slownika\');
    function ws_Slownik($s, $r){
      $odp = DictWs($s, $r);
      file_put_contents(\".././../2.txt\", $odp);
        if ($odp == \"0\" && 1>2) {
        return new soapval(\'return\',\'xsd:string\', \"Zle\");
        }
        else {
        $x = new soapval(\'slownik\',\'xsd:string\', $odp);
        file_put_contents(\".././../Seria.txt\", $x->serialize());
        return substr($odp,0,400) . \" itd. ale  tylko do 522 znakow\";
        }
    }
    The very same function is OK (but it returns small amount of info)
    =========================================================
    $server->register(\'ws_Auth\',   array(\'s\' => \'xsd:string\', \'r\' => \'xsd:string\'),  array(\'total\' => \'xsd:integer\'),  $ns, \"$ns#Auth\",  \'rpc\',  \'encoded\',  \'Zwraca informacje o autoryzacji uzytkownika\'  );
    function ws_Auth($s, $r){
        $odp = AuthWs($s, $r);
         return new soapval(\'return\',\'xsd:string\', $odp);
    }

     
  • **Hi

    I can show you how I have done it with invoices:**

        $Ny->register('GetInvoPDF',
                array('InvoNo' => 'xsd:integer'),   // input parameters
                array('return'  => 'xsd:xml'),          // output parameter             
                $NS,                                                // namespace
                'GetInvoPDF',                                 // soapaction
                'rpc',                                                 // style
                'encoded',                                      // use
                'Get invoice as PDF'                    // documentation
                );

        function GetInvoPDF($InvoNo){

           IF(file_exists("C:\\Program Files\\Invoice\\".$InvoNo.".pdf")){
          
                $file = fopen("C:\\Program Files\\Invoice\\".$InvoNo.".pdf","r");   
                $contents = '';
           
                while (!feof($file)) {
                    $contents .= fread($file, 1024);
                }
               
                fclose($file);     
                $Reply = "<Status>OK</Status><PDFdata>".base64_encode($contents)."</PDFdata>";
               
            }ELSE{
               
                $Reply = "<Status>NoFile</Status>";
               
            }
          return new soapval('return','xsd:xml',html_entity_decode($Reply));
      }