php - 错误 : Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR

标签 php web-services soap wsdl

我尝试将 pdf 文件转换为图像。

我检查这个website ,并按照所有步骤说明进行操作。

1.obtain an api license key
2.download the API Class
3.Deploy the php file
4.create my pdf 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();

?>

这是发生错误的 API 类 PdfaidServices.php

 <?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";
              }
            }
   }
    ?>

拜托!!有人可以帮助我吗?

最佳答案

在我的机器上工作正常。您是否具有与上述 wsdl 的网络连接?当您将该 wsdl URL 粘贴到浏览器中时会发生什么?

关于php - 错误 : Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31611061/

相关文章:

PHP 脚本不会将 CSV 导入 MySQL

php - Doctrine1 和 Doctrine2 之间有什么区别?

java - Jython SOAP Web 服务

java - Apache CXF 异常 : java. lang.RuntimeException:找不到地址的管道启动器

php - mysql更新语法中的columname可以是变量吗?

php - 需要帮助创建基于 ui 过滤器值的查询

web-services - ColdFusion 11 - 使用 axis-1 Web 服务

c# - 如何调试此 Web 服务?

ruby - 如何在 Ruby 中创建 SOAP 信封?

objective-c - "Predicate Mismatch for View"是什么意思