简体   繁体   中英

Error: Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR

I tried to convert a pdf file to an image.

I check this website , and follow all step instructions.

1.obtain an api license key
2.download the API Class
3.Deploy the php file
4.create my pdf file

But when i run my file happens this error:

The part of the bold code is where raises the error

Could anyone help me please? I would forever gratefull.

This is my file

<?php 
include 'PdfaidServices.php';
$myPdf2Jpg = new Pdf2Jpg();
$myPdf2Jpg->apiKey = "xxxxxxxxxx";
$myPdf2Jpg->inputPdfLocation = "pdf_file.pdf";
$myPdf2Jpg->outputZipLocation = "UploadedPdf/pdf2jpg.zip";
$myPdf2Jpg->outputImageFormat = ".jpg";
$myPdf2Jpg->imageQuality = 50;
$result = $myPdf2Jpg->Pdf2Jpg();

?>

This is API Class PdfaidServices.php where erros happens

 <?php
   class Xps2PdfConverter
   {
        public $apiKey = "";
        public $inputXpsLocation = "";
        public $outputPdfLocation = "";
        public $pdfAuthor = "";
        public $pdfTitle = "";
        public $pdfSubject = "";
        public $pdfKeywords = "";

            function Xps2PdfConvert()
            { 
              if($this->apiKey == "")
              return "Please specify ApiKey";
              if($this->outputPdfLocation == "")
              return "Please specify location to save output Pdf";
              if($this->inputXpsLocation == "")
              return "Please specify input XPS file Location";
              else
              {
                $fileStream = file_get_contents($this->inputXpsLocation);
              }

              $parameters = array("FileByteStream" => $fileStream);
              $wsdl = "http://apis.pdfaid.com/pdfaidservices/Service1.svc?wsdl";
              $endpoint = "http://apis.pdfaid.com/pdfaidservices/Service1.svc";
              $option=array('trace'=>1);
              $client = new SoapClient($wsdl, $option);

              $headers[] = new SoapHeader('http://tempuri.org/', 'apikey', $this->apiKey);
              $headers[] = new SoapHeader('http://tempuri.org/', 'pdfTitle', $this->pdfTitle);
              $headers[] = new SoapHeader('http://tempuri.org/', 'pdfAuthor', $this->pdfAuthor);
              $headers[] = new SoapHeader('http://tempuri.org/', 'pdfSubject', $this->pdfSubject);
              $headers[] = new SoapHeader('http://tempuri.org/', 'pdfKeywords', $this->pdfKeywords);
              $headers[] = new SoapHeader('http://tempuri.org/', 'responseResult', "test");   
              $client->__setSoapHeaders($headers);

              $result = $client->Xps2Pdf($parameters);
              $clientResponse = $client->__getLastResponse();

              if($clientResponse == "APINOK")
              return "API is not Valid";
              if($clientResponse == "NOK")
              return "Error Occured";
              else
              {
                $fp = fopen($this->outputPdfLocation, 'wb');
                fwrite($fp, $result->FileByteStream);
                fclose($fp);
                return "OK";
              }
            }
   }

   class Pdf2Jpg
   {
        public $apiKey = "";
        public $outputImageFormat = "";
        public $inputPdfLocation = "";
        public $outputZipLocation = "";
        public $imageQuality = 50;

            function Pdf2Jpg()
            { 
              if($this->apiKey == "")
              return "Please specify ApiKey";
              if($this->outputImageFormat == "")
              return "Please specify Output Image Format";
              if($this->outputZipLocation == "")
              return "Please specify Output Zip File Location";
              if($this->inputPdfLocation == "")
              return "Please specify input Pdf file Location";
              else
              {
                $fileStream = file_get_contents($this->inputPdfLocation);
              }
              $parameters = array("FileByteStream" => $fileStream);
              $wsdl = "http://apis.pdfaid.com/pdfaidservices/Service1.svc?wsdl";
              $endpoint = "http://apis.pdfaid.com/pdfaidservices/Service1.svc";
              $option=array('trace'=>1);

$client = new SoapClient($wsdl, $option);

              $headers[] = new SoapHeader('http://tempuri.org/', 'apikey', $this->apiKey);
              $headers[] = new SoapHeader('http://tempuri.org/', 'outputFormat', $this->outputImageFormat);
              $headers[] = new SoapHeader('http://tempuri.org/', 'imageQuality', $this->imageQuality);
              $headers[] = new SoapHeader('http://tempuri.org/', 'responseResult', "test");
              $client->__setSoapHeaders($headers);

              $result = $client->Pdf2Jpg($parameters);
              $clientResponse = $client->__getLastResponse();

              if($clientResponse == "APINOK")
              return "API is not Valid";
              if($clientResponse == "NOK")
              return "Error Occured";
              else
              {
                $fp = fopen($this->outputZipLocation, 'wb');
                fwrite($fp, $result->FileByteStream);
                fclose($fp);
                return "OK";
              }
            }
   }
    ?>

Please!! Someone can help me please?

Works fine from my machine. Do you have network connectivity to the said wsdl? What happens when you stick that wsdl URL in a browser?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM