Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
215 views
in Technique[技术] by (71.8m points)

Error when trying to delete or cancel fedex shipping through PHP wrapper

I use JeremyDunn's Fedex API integration - https://github.com/JeremyDunn/php-fedex-api-wrapper

My delete-pending-shipment.php

$webAuthenticationDetail = new ComplexTypeWebAuthenticationDetail();
$webAuthenticationDetail->setUserCredential($userCredential);

$clientDetail = new ComplexTypeClientDetail();
$clientDetail
    ->setAccountNumber(FEDEX_ACCOUNT_NUMBER)
    ->setMeterNumber(FEDEX_METER_NUMBER);

$version = new ComplexTypeVersionId();
$version
    ->setServiceId('ship')
    ->setMajor(23)
    ->setIntermediate(0)
    ->setMinor(0);

$trackingId = new ComplexTypeTrackingId();
$trackingId
    ->setTrackingNumber('111111111111')
    ->setTrackingIdType(SimpleTypeTrackingIdType::_FEDEX);

$deleteShipmentRequest = new ComplexTypeDeleteShipmentRequest();
$deleteShipmentRequest->setWebAuthenticationDetail($webAuthenticationDetail);
$deleteShipmentRequest->setClientDetail($clientDetail);
$deleteShipmentRequest->setVersion($version);
$deleteShipmentRequest->setTrackingId($trackingId);
$deleteShipmentRequest->setDeletionControl(SimpleTypeDeletionControlType::_DELETE_ALL_PACKAGES);


$validateShipmentRequest = new ShipServiceRequest();
$validateShipmentRequest->getSoapClient()->__setLocation('https://ws.fedex.com:443/web-services/ship');
$response = $validateShipmentRequest->getDeleteShipmentReply($deleteShipmentRequest);

var_dump($response);

My cancel-pending-shipment.php

<?php

//require_once 'credentials.php';
require_once 'example.credentials.php';
require_once 'bootstrap.php';

use FedExShipServiceRequest;
use FedExShipServiceComplexType;
use FedExShipServiceSimpleType;

$trackingNumber = '111111111111';

$cancelPendingShipmentRequest = new ComplexTypeCancelPendingShipmentRequest();
$cancelPendingShipmentRequest->WebAuthenticationDetail->UserCredential->Key = FEDEX_KEY;
$cancelPendingShipmentRequest->WebAuthenticationDetail->UserCredential->Password = FEDEX_PASSWORD;
$cancelPendingShipmentRequest->ClientDetail->AccountNumber = FEDEX_ACCOUNT_NUMBER;
$cancelPendingShipmentRequest->ClientDetail->MeterNumber = FEDEX_METER_NUMBER;
$cancelPendingShipmentRequest->Version->ServiceId = 'ship';
$cancelPendingShipmentRequest->Version->Major = 12;
$cancelPendingShipmentRequest->Version->Intermediate = 1;
$cancelPendingShipmentRequest->Version->Minor = 0;
$cancelPendingShipmentRequest->TrackingId->TrackingNumber = $trackingNumber;


$shipServiceRequest = new Request();
$cancelPendingShipmentReply = $shipServiceRequest->getCancelPendingShipmentReply($cancelPendingShipmentRequest);

var_dump($cancelPendingShipmentReply);

When I run the above code I get the following error:

delete-pending-shipment.php

Fatal error:  Uncaught TypeError: Argument 1 passed to FedExAbstractComplexType::populateFromStdClass() must be an instance of stdClass, null given, called in C:xampphtdocsfedex-apisrcFedExShipServiceRequest.php on line 95 and defined in C:xampphtdocsfedex-apisrcFedExAbstractComplexType.php:139
Stack trace:
#0 C:xampphtdocsfedex-apisrcFedExShipServiceRequest.php(95): FedExAbstractComplexType->populateFromStdClass(NULL)
#1 C:xampphtdocsfedex-apiexamplesdelete-pending-shipment.php(46): FedExShipServiceRequest->getDeleteShipmentReply(Object(FedExShipServiceComplexTypeDeleteShipmentRequest))
#2 {main}
  thrown in C:xampphtdocsfedex-apisrcFedExAbstractComplexType.php on line 139

cancel-pending-shipment.php

Fatal error: Uncaught Error: Class 'FedExShipServiceComplexTypeCancelPendingShipmentRequest' not found in C:xampphtdocsfedex-apiexamplescancel-pending-shipment.php:13 
Stack trace: 
#0 {main} thrown in C:xampphtdocsfedex-apiexamplescancel-pending-shipment.php on line 13

My rete-request.php is working so I can create orders, but when I am trying to cancel or delete fedex shipping, it shows the error.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...