Fedex形式错误

时间:2015-09-05 07:02:06

标签: php fedex

这是HTML表单,当我提交表单时会出现以下错误

  

致命错误:未捕获的SoapFault异常:[WSDL] SOAP-ERROR:解析WSDL:无法加载   ' ../../../ WSDL / ShipService_v17.wsdl' :无法加载外部实体   " ../../../ WSDL / ShipService_v17.wsdl"在   d:\主机\ 10722104 \ HTML \联邦快递\ PHP \ ShipWebServiceClient \快\国产\ ShipWebServiceClient.php5:17   堆栈跟踪:#0   d:\主机\ 10722104 \ HTML \联邦快递\ PHP \ ShipWebServiceClient \快\国产\ ShipWebServiceClient.php5(17):   SoapClient-> SoapClient(' ../../../ wsdl / S ...',数组)#1 {main}抛出   在   d:\主机\ 10722104 \ HTML \联邦快递\ PHP \ ShipWebServiceClient \快\国产\ ShipWebServiceClient.php5   第17行

 `   <form id="form1"  method="post" action="php/ShipWebServiceClient/Express /Domestic/ShipWebServiceClient.php5">
  <div class="from_box">
        <div class="top_from_hed">Fill out this Form to Get<br />FREE &nbsp;<img src="images/fed-ex-butoon.png" />Shiping! </div>

        <div class="all_felds">1. What are you sending?<br />
   <input name="" type="checkbox"  value=""onclick="showfirstbox();             "  name="sending" />  Diamond <input                name="" type="checkbox" value="" />  Gold <input name="" type="checkbox"            value="" />  Silver <br />

 <br /><br />
     <input type="radio" name="printll" id="secondbox" />Print label
      <table width="259" border="0" cellspacing="0" cellpadding="0">
   <tr>
  <td width="91" height="29">First Name:</td>
<td width="10">&nbsp;</td>
<td width="162">
  <label>
    <input type="text" name="fname" id="textfield" />
    </label>
      </form>    </td>
       </tr>
     <tr>
  <td width="91" height="28">Last Name:</td>
  <td width="10">&nbsp;</td>
  <td width="162">
   <label>
    <input type="text" name="lname" id="textfield" />
    </label>
</td>
  </tr>
  <tr>
  <td width="91" height="27">Street Address:</td>
  <td width="10">&nbsp;</td>
  <td width="162">
  <label>
    <input type="text" name="street" id="textfield" />
    </label>
 </td>
      </tr>
    <tr>
     <td width="91" height="27">Email Address:</td>
        <td width="10">&nbsp;</td>
       <td width="162">
         <label>
       <input type="text" name="eeemail" id="textfield" />
      </label>
      </td>
     </tr><tr>
     <td width="91" height="28">Apt/Suite:</td>
     <td width="10">&nbsp;</td>
      <td width="162">
     <label>
       <input type="text" name="textfield" id="textfield" />
       </label>
      </td>
    </tr><tr>
     <td width="91" height="27">City:</td>
     <td width="10">&nbsp;</td>
     <td width="162">
     <label>
       <input type="text" name="city" id="textfield" />
       </label>
      </td>
   </tr><tr>
    <td width="91" height="27">Country:</td>
   <td width="10">&nbsp;</td>
   <td width="162">
    <label>
      <input type="text" name="country" id="textfield" />
      </label>
   </td>
  </tr><tr>
   <td width="91" height="27">State:</td>
   <td width="10">&nbsp;</td>
   <td width="162">
    <label>
      <input type="text" name="state_hid" id="textfield" />
      </label>
   </td>
  </tr><tr>
<td width="91" height="28">Zip Code:</td>
<td width="10">&nbsp;</td>
<td width="162">
  <label>
    <input type="text" name="postalcode" id="textfield" />
    </label>
  </td>
        </tr>
       <tr>
    <td width="91" height="26">Phone no:</td>
   <td width="10">&nbsp;</td>
    <td width="162">
     <label>
     <input type="text" name="phone" id="textfield" />
       </label>
      </td>
    </tr>
    <tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
           </tr>
      <tr>
      <td>&nbsp;</td>
   <td>&nbsp;</td>
    <td><table width="157" height="19" border="0" cellpadding="0" ce  llspacing="0">
  <tr>
        <td width="30">&nbsp;</td>
       <td width="74"><div class="submit_from_hed">
       <a href="#"><font color="#333333">
    <input type="submit"name="fdesubmit"   value="submit"  /></font></a>
      </div></td>
        <td width="53">&nbsp;</td>
       </tr>
           </table></td>
         </tr>
        <tr>
    <td>&nbsp;</td>
        <td>&nbsp;</td>
  <td><table width="156" border="0" cellspacing="0" cellpadding="0">
       <tr>
      <td width="28">&nbsp;</td>
    <td width="128">&nbsp;</td>
  </tr>
  </table></td>
</tr>
</table>`

这是我用于fedex表单集成的代码

    `<?php
// Copyright 2009, FedEx Corporation. All rights reserved.
// Version 12.0.0
  require_once('../../../library/fedex-common.php5');

     //The WSDL is not included with the sample code.
   //Please include and reference in $path_to_wsdl variable.
         $path_to_wsdl = "../../../wsdl/ShipService_v17.wsdl";

      define('SHIP_LABEL', time() . '.png');  // PNG label file.    Change    to          file-extension .pdf for creating a PDF label (e.g. shiplabel.pdf)

    ini_set("soap.wsdl_cache_enabled", "0");
    ini_set("soap.wsdl_cache", "0");
    ini_set("display_errors","On");
   ini_set("track_errors","On");
  $client = new SoapClient($path_to_wsdl, array('trace' => 1)); 

     $name='';
   $invoice_num='INV' . time() * 3;
    $option=$_REQUEST['option'];
  $request['WebAuthenticationDetail'] = array(
'UserCredential' =>array(
    'Key' => getProperty('key'), 
    'Password' => getProperty('password')
)
 );
       $request['ClientDetail'] = array(
         'AccountNumber' => getProperty('shipaccount'), 
  'MeterNumber' => getProperty('meter')
    );
        $request['TransactionDetail'] = array('CustomerTransactionId' =>     '*** Express Domestic Shipping Request using PHP ***');
    $request['Version'] = array(
    'ServiceId' => 'ship', 
      'Major' => '10', 
'Intermediate' => '0', 
'Minor' => '0'
     );
         $request['RequestedShipment'] = array(
    'ShipTimestamp' => date('c'),
    'DropoffType' => 'REGULAR_PICKUP', 
         'ServiceType' => 'FEDEX_EXPRESS_SAVER', 

          'PackagingType' => 'YOUR_PACKAGING',  
         'Shipper' => addShipper(),
          'Recipient' => addRecipient(),
         'ShippingChargesPayment' => addShippingChargesPayment(),
        'SpecialServicesRequested' => addSpecialServices(),
        'LabelSpecification' => addLabelSpecification(), 
         'PackageCount' => 1,
                   'RequestedPackageLineItems' => array(
            '0' => addPackageLineItem1()
          )
            );



    try {
       if(setEndpoint('changeEndpoint')){
    $newLocation = $client->__setLocation(setEndpoint('endpoint'));
      }

        $response = $client->processShipment($request);  // FedEx web service invocation

          if ($response->HighestSeverity != 'FAILURE' && $response->HighestSeverity != 'ERROR'){        
    printSuccess($client, $response);

    $fp = fopen('../label/' . SHIP_LABEL, 'wb');   
    fwrite($fp,          $response->CompletedShipmentDetail->AssociatedShipments->Label->Parts->Image);         //Create COD Return PNG or PDF file
      fclose($fp);
            $message1="Transaction Successful<br>";

     if($option==$_POST['printll'])
    {
        $link=SHIP_LABEL;
        $message='<div id="label1" style="margin-bottom:-10px;">
        <div id="number"></div>
        <div id="message"><a href="'.'../print_label.php?id='. $link    .'">   <h3 style="color:#666;">Click here to print your label</h3></a>
           </div>
          </div>';

          $message.='<div id="label1">
        <a href="http://www.fedex.com/Dropoff/start"><div  id="second">         </div></a>
          </div>';

          $message.='<div id="label1">
          <div id="third"></div>
        </div>';
    }
   }else{


 writeToLog($client);  }  // Write to log file

}
 catch (SoapFault $exception) {
      printFault($exception, $client);
 }
           function addShipper(){
           $name=$_POST['fname'] . " " . $_POST['lname'];

         $shipper = array(

    'Contact' => array(
        'PersonName' => $name,
        'CompanyName' => '',
        'PhoneNumber' => $_POST['phone'],
                    'Email' => $_POST['eeemail'],

    ),
    'Address' => array(
        'StreetLines' => array($_POST['street']),
        'City' => $_POST['city'],
        'StateOrProvinceCode' => $_REQUEST['state_hid'],
        'PostalCode' => $_REQUEST['postalcode'],
        'CountryCode' => $_REQUEST['country'])

);
   return $shipper;
     }
      function addRecipient(){
   $recipient = array(
    'Contact' => array(
        'Contact' => array(
        'PersonName' => 'CRJ Inc',
        'CompanyName' => 'CRJ Inc c/o NDB',
        'PhoneNumber' => '800-574-8820'),
       'Address' => array(
        'StreetLines' => array('4010 Oak Circle'),
        'City' => 'Boca Raton',
        'StateOrProvinceCode' => 'FL',
        'PostalCode' => '33431',
        'CountryCode' => 'US',
        'Residential' => false)
        )
) ;
     return $recipient ;                                        
     }
         function addShippingChargesPayment(){
     $shippingChargesPayment = array('PaymentType' => 'SENDER',
    'Payor' => array(
    'ResponsibleParty' => array(
        'AccountNumber' => getProperty('billaccount'),
        'Contact' => null,
        'Address' => array(
            'CountryCode' => 'US')
        )
    )
);
         return $shippingChargesPayment;
   }
             function addLabelSpecification(){
                 $labelSpecification = array(
              'LabelFormatType' => 'COMMON2D', // valid values COMMON2D,            LABEL_DATA_ONLY
             'ImageType' => 'PNG',  // valid values DPL, EPL2, PDF, ZPLII and PNG
       'LabelStockType' => 'PAPER_7X4.75'
        );
           return $labelSpecification;
            }
                         function addSpecialServices1(){
                   $specialServices = array(
                        'SpecialServiceTypes' => array('COD'),
                     'CodDetail' => array(
                         'CodCollectionAmount' => array(
                   'Currency' => 'USD', 
                       'Amount' => 150
             ),
                 'CollectionType' => 'ANY' // ANY, GUARANTEED_FUNDS
               )
             );
                return $specialServices; 
                    }
                          function addCustomClearanceDetail(){
               $customerClearanceDetail = array(
              'DutiesPayment' => array(
        'PaymentType' => 'SENDER', // valid values RECIPIENT, SENDER and THIRD_PARTY
        'Payor' => array(
            'AccountNumber' => getProperty('dutyaccount'),
            'CountryCode' => 'CA'
        )
    ),
    'DocumentContent' =>           'NON_DOCUMENTS',                                                                                            
    'CustomsValue' => array(
        'Currency' => 'USD', 
        'Amount' => 20.0
    ),
'Commodities' => array(
    '0' => array(
        'NumberOfPieces' => 1,
        'Description' => 'Books',
        'CountryOfManufacture' => 'US',
        'Weight' => array(
            'Units' => 'LB', 
            'Value' => 1.0
        ),
        'CustomsValue' => array(
            'Currency' => 'USD', 
            'Amount' => 20.000000
        )
    )
),
'ExportDetail' => array(
    'B13AFilingOption' => 'NOT_REQUIRED'
        )
  );
      return $customerClearanceDetail;
       }


      function addPackageLineItem1(){
        $packageLineItem = array(
    'SequenceNumber'=>1,
    'GroupPackageCount'=>1,
    'InsuredValue' => array(
        'Amount' => 20.00, 
        'Currency' => 'USD'
    ),
    'Weight' => array(
        'Value' => 1.0,
        'Units' => 'LB'
    ),
    'Dimensions' => array(
        'Length' => 20,
        'Width' => 10,
        'Height' => 10,
        'Units' => 'IN'
    ),
    'CustomerReferences' => array(
        '0' => array(
            'CustomerReferenceType' => 'CUSTOMER_REFERENCE', 
            'Value' => 'GR' . time() * 7
        ), // valid values CUSTOMER_REFERENCE, INVOICE_NUMBER, P_O_NUMBER and SHIPMENT_INTEGRITY
        '1' => array(
            'CustomerReferenceType' => 'INVOICE_NUMBER', 
            'Value' => $invoice_num 
        ),
        '2' => array(
            'CustomerReferenceType' => 'P_O_NUMBER', 
            'Value' => 'PO' .time() * 5
        )
    )
);
      return $packageLineItem;
     }
        ?>

`

请找到一些解决方案,以便我能够从网站创建标签

0 个答案:

没有答案