2

我正在尝试构建和应用程序来调用由 AAA Cooper Transportation 托管的 Web 服务。

AAA Cooper 说明和 WSDL

我最终使用wsdl2phpgenerator来生成调用服务所需的代码。

我正在尝试构建和应用程序来调用由 AAA Cooper Transportation 托管的 Web 服务。
我正在尝试构建和应用程序来调用由 AAA Cooper Transportation 托管的 Web 服务。
我正在尝试构建和应用程序来调用由 AAA Cooper Transportation 托管的 Web 服务。

$ProNo="73266840";
$ImageType="BL";
$ImageFormat="PDF";
$Token="#######-####-###-######-########";

ActDocumentSearch.php

        <?php

    include_once('GetDocument.php');
    include_once('ActImgSearchServiceRequestVO.php');
    include_once('GetDocumentResponse.php');
    include_once('ActImgSearchServiceResponseVO.php');
    include_once('UserCredentials.php');


    /**
     * 
     */
    class ActDocumentSearch extends SoapClient
    {

      /**
       * 
       * @var array $classmap The defined classes
       * @access private
       */
      private static $classmap = array(
        'GetDocument' => 'GetDocument',
        'ActImgSearchServiceRequestVO' => 'ActImgSearchServiceRequestVO',
        'GetDocumentResponse' => 'GetDocumentResponse',
        'ActImgSearchServiceResponseVO' => 'ActImgSearchServiceResponseVO',
        'UserCredentials' => 'UserCredentials');

      /**
       * 
       * @param array $config A array of config values
       * @param string $wsdl The wsdl file to use
       * @access public
       */
      public function __construct(array $options = array(), $wsdl = 'http://www.aaacooper.com/ws/ActDocumentSearch.asmx?wsdl')
      {
        foreach(self::$classmap as $key => $value)
        {
          if(!isset($options['classmap'][$key]))
          {
            $options['classmap'][$key] = $value;
          }
        }

        parent::__construct($wsdl, $options);
      }

      /**
       * 
       * @param GetDocument $parameters
       * @access public
       */
      public function GetDocument(GetDocument $parameters)
      {
        return $this->__soapCall('GetDocument', array($parameters));
      }

    }


<?php

class UserCredentials
{

  /**
   * 
   * @var string $token
   * @access public
   */
  public $token;

  /**
   * 
   * @param string $token
   * @access public
   */
  public function __construct($token)
  {
    $this->token = $token;
  }

}

<?php

class GetDocumentResponse
{

  /**
   * 
   * @var ActImgSearchServiceResponseVO $GetDocumentResult
   * @access public
   */
  public $GetDocumentResult;

  /**
   * 
   * @param ActImgSearchServiceResponseVO $GetDocumentResult
   * @access public
   */
  public function __construct($GetDocumentResult)
  {
    $this->GetDocumentResult = $GetDocumentResult;
  }

}

<?php

class GetDocument
{

  /**
   * 
   * @var ActImgSearchServiceRequestVO $actImgSearchServiceRequestVO
   * @access public
   */
  public $actImgSearchServiceRequestVO;

  /**
   * 
   * @param ActImgSearchServiceRequestVO $actImgSearchServiceRequestVO
   * @access public
   */
  public function __construct($actImgSearchServiceRequestVO)
  {
    $this->actImgSearchServiceRequestVO = $actImgSearchServiceRequestVO;
  }

}
<?php

class ActImgSearchServiceResponseVO
{

  /**
   * 
   * @var string $ProNo
   * @access public
   */
  public $ProNo;

  /**
   * 
   * @var string $ImageType
   * @access public
   */
  public $ImageType;

  /**
   * 
   * @var string $ImageFormat
   * @access public
   */
  public $ImageFormat;

  /**
   * 
   * @var anyType $ImageUrl
   * @access public
   */
  public $ImageUrl;

  /**
   * 
   * @var string $ErrorMessage
   * @access public
   */
  public $ErrorMessage;

  /**
   * 
   * @param string $ProNo
   * @param string $ImageType
   * @param string $ImageFormat
   * @param anyType $ImageUrl
   * @param string $ErrorMessage
   * @access public
   */
  public function __construct($ProNo, $ImageType, $ImageFormat, $ImageUrl, $ErrorMessage)
  {
    $this->ProNo = $ProNo;
    $this->ImageType = $ImageType;
    $this->ImageFormat = $ImageFormat;
    $this->ImageUrl = $ImageUrl;
    $this->ErrorMessage = $ErrorMessage;
  }

}
<?php

class ActImgSearchServiceRequestVO
{

  /**
   * 
   * @var string $ProNo
   * @access public
   */
  public $ProNo;

  /**
   * 
   * @var string $ImageType
   * @access public
   */
  public $ImageType;

  /**
   * 
   * @var string $ImageFormat
   * @access public
   */
  public $ImageFormat;

  /**
   * 
   * @param string $ProNo
   * @param string $ImageType
   * @param string $ImageFormat
   * @access public
   */
  public function __construct($ProNo, $ImageType, $ImageFormat)
  {
    $this->ProNo = $ProNo;
    $this->ImageType = $ImageType;
    $this->ImageFormat = $ImageFormat;
  }

}
4

1 回答 1

1

将此添加到主类。我从表格中获取 PRO 和 DOC 类型。然后我将用户重定向到请求图像。这是我看到的第一个例子。不确定代码是否写得很好但可以工作。

        $ProNo=$_GET['PRO'];
        $ImageType=$_GET['DocType'];
        $ImageFormat="PDF";
        $Token="####################################";

        try{

    $actImage = new ActImgSearchServiceRequestVO($ProNo, $ImageType, $ImageFormat);
    $creds = new UserCredentials($Token);
    $getter = new GetDocument($actImage);
    $searcher = new ActDocumentSearch(array('trace' => 1));

    $header = new SoapHeader('http://www.aaacooper.com/','UserCredentials',$creds);
    $searcher->__setSoapHeaders($header);
    $reciever = $searcher->GetDocument($getter,array($actImage,$creds));  
        }
        catch(SoapFault $exception)
        {
            echo $exception->getMessage();
        }

    if ($reciever->GetDocumentResult->ImageUrl == ''){
    echo '<h1>' . $reciever->GetDocumentResult->ErrorMessage . '</h1>';
    }else{
     header( 'Location: ' . $reciever->GetDocumentResult->ImageUrl ) ;
     }
    ?>
于 2013-06-27T12:28:42.580 回答