Replies: 4 comments 4 replies
-
It's not required to override the SoapClient. Can you paste (take care to replace any credentials first 😉):
|
Beta Was this translation helpful? Give feedback.
0 replies
-
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use FedexRateService\ServiceType\Get;
use FedexRateService\StructType\RateRequest;
use FedexRateService\StructType\WebAuthenticationDetail;
use FedexRateService\StructType\WebAuthenticationCredential;
use FedexRateService\StructType\ClientDetail;
use FedexRateService\StructType\Localization;
use FedexRateService\StructType\VersionId;
use FedexRateService\StructType\TransactionDetail;
use FedexRateService\StructType\ConsolidationKey;
use FedexRateService\StructType\Weight;
use FedexRateService\StructType\Money;
use FedexRateService\StructType\ShipmentAuthorizationDetail;
use FedexRateService\StructType\Contact;
use FedexRateService\StructType\Address;
use FedexRateService\StructType\Party;
use FedexRateService\StructType\ContactAndAddress;
use FedexRateService\StructType\Payment;
use FedexRateService\StructType\Payor;
use FedexRateService\StructType\RequestedPackageLineItem;
use FedexRateService\StructType\Dimensions;
use FedexRateService\StructType\RequestedShipment;
use FedexRateService\ClassMap;
class FedexTest extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'modules:FedexTest';
/**
* Optional.
* Allows the caller to specify that the transit time and
* commit data are to be returned in the reply.
* Valid values are:
* • TRUE
* • FALSE
*/
protected $returnTransitAndCommit=true;
/**
* Optional.
* Candidate carriers for rate-shopping use case. This
* element is only considered if
* RequestedShipment/ServiceType is omitted.
*/
protected $carrierCodes = [];
/**
* ?????
*/
protected $variableOptions;
/**
* Create a new command instance.
*
* @return void
*/
protected $rateRequestTypes = ['LIST'];
protected $packageCount = 1;
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
// dd(
// config("fedexconfig.uk.FEDEX_ACCOUNT_NUMBER"),
// config("fedexconfig.uk.FEDEX_METER_NUMBER"),
// config("fedexconfig.uk.FEDEX_KEY"),
// config("fedexconfig.uk.FEDEX_PASSWORD")
// );
$localization = new Localization("EN","gb");
$clientDetail = new ClientDetail(
config("fedexconfig.uk.FEDEX_ACCOUNT_NUMBER"),
config("fedexconfig.uk.FEDEX_METER_NUMBER"),
'dgrgrgrg',
"EMEA",
$localization
);
$webAuthenticationCredential = new WebAuthenticationCredential(
config("fedexconfig.uk.FEDEX_KEY"),
config("fedexconfig.uk.FEDEX_PASSWORD"),
);
// dd(
// $webAuthenticationCredential->getKey(),
// $webAuthenticationCredential->getPassword()
// );
$webAuthenticationDetail = new WebAuthenticationDetail($webAuthenticationCredential, $webAuthenticationCredential);
//major 21,28
$versionId = new VersionId(
"crs",
28,
0,
0
);
$transactionDetail = new TransactionDetail(
'CustomerTransactionId',
$localization
);
/**
* e <xs:simpleType name="ConsolidationType">
* <xs:restriction base="xs:string">
* <xs:enumeration value="INTERNATIONAL_DISTRIBUTION_FREIGHT"/>
* <xs:enumeration value="INTERNATIONAL_ECONOMY_DISTRIBUTION"/>
* <xs:enumeration value="INTERNATIONAL_GROUND_DISTRIBUTION"/>
* <xs:enumeration value="INTERNATIONAL_PRIORITY_DISTRIBUTION"/>
* <xs:enumeration value="TRANSBORDER_DISTRIBUTION"/>
*/
$consolidationKey = new ConsolidationKey(
"INTERNATIONAL_ECONOMY_DISTRIBUTION",
"orderid1234",
"2021-23-02"
);
$weight = new Weight(
"KG",
1.07
);
$money = new Money(
"GBP",
1
);
$shipmentAuthorizationDetail = new ShipmentAuthorizationDetail(
config("fedexconfig.uk.FEDEX_ACCOUNT_NUMBER")
);
$shipContact = new Contact();
$shipContact->setContactId("".config("ukaddress.customer_id"));
$shipContact->setPersonName(config("ukaddress.full_name"));
$shipContact->setTitle("Mr");
$shipContact->setCompanyName(config("ukaddress.company"));
$shipContact->setPhoneNumber(config("ukaddress.phone"));
$shipContact->setPhoneExtension(config("ukaddress.extension"));
// $shipContact->setTollFreePhoneNumber("");
// $shipContact->setPagerNumber("");
// $shipContact->setFaxNumber($faxNumber);
$shipContact->setEMailAddress(config("ukaddress.email"));
$shipAddress = new Address();
$shipAddress->setStreetLines(
[
'Downclose Farm'
]
);
$shipAddress->setCity(config("ukaddress.city"));
$shipAddress->setStateOrProvinceCode(config("ukaddress.state_code"));
$shipAddress->setPostalCode(config("ukaddress.postcode"));
// $shipAddress->setUrbanizationCode($urbanizationCode)
$shipAddress->setCountryCode(config("ukaddress.state_code"));
$shipAddress->setCountryName(config("ukaddress.country"));
$shipAddress->setResidential(false);
$shipParty = new Party(
config("fedexconfig.uk.FEDEX_ACCOUNT_NUMBER"),
[],
$shipContact,
$shipAddress
);
$recipContact = new Contact();
// $recipContact->setContactId("10");
// $recipContact->setPersonName('Calogero Pumpignano');
// $recipContact->setTitle("Mr");
// $recipContact->setCompanyName(config("ukaddress.company"));
// $recipContact->setPhoneNumber("153434340");
// $recipContact->setPhoneExtension("0033");
// $recipContact->setTollFreePhoneNumber("");
// $recipContact->setPagerNumber("");
// $recipContact->setFaxNumber($faxNumber);
// $recipContact->setEMailAddress(config("ukaddress.email"));
$recipAddress = new Address();
$recipAddress->setStreetLines(
[
'69 Port de la Rapée'
]
);
$recipAddress->setCity('Paris');
$recipAddress->setStateOrProvinceCode("FR");
$recipAddress->setPostalCode("75012");
// $recipAddress->setUrbanizationCode($urbanizationCode)
$recipAddress->setCountryCode("FR");
$recipAddress->setCountryName("France");
$recipAddress->setResidential(false);
$recipParty = new Party(
config("fedexconfig.uk.FEDEX_ACCOUNT_NUMBER"),
[],
null,
// $recipContact,
$recipAddress
);
$contactAndAddress = new ContactAndAddress(
$shipContact,
$shipAddress
);
/**
* <xs:simpleType name="PaymentType">
* <xs:restriction base="xs:string">
* <xs:enumeration value="ACCOUNT"/>
* <xs:enumeration value="CASH"/>
* <xs:enumeration value="COLLECT"/>
* <xs:enumeration value="CREDIT_CARD"/>
* <xs:enumeration value="RECIPIENT"/>
* <xs:enumeration value="SENDER"/>
* <xs:enumeration value="THIRD_PARTY"/>
*/
$payor = new Payor(
$shipParty
);
$payment = new Payment(
"SENDER",
$payor
);
$requestedPackageLineItems = array();
$requestedPackageLineItem = new RequestedPackageLineItem();
$requestedPackageLineItem->setSequenceNumber(1);
$requestedPackageLineItem->setGroupNumber(1);
$requestedPackageLineItem->setGroupPackageCount(1);
// $requestedPackageLineItem->setVariableHandlingChargeDetail($variableHandlingChargeDetail)
// $requestedPackageLineItem->setInsuredValue($insuredValue);
$requestedPackageLineItem->setWeight( new Weight(
"KG",
1.07
));
$requestedPackageLineItem->setDimensions(new Dimensions(
14,
7,
26,
"CM"
)
);
$requestedPackageLineItem->setPhysicalPackaging("OTHER");
// $requestedPackageLineItem->setAssociatedFreightLineItems($associatedFreightLineItems)
// $requestedPackageLineItem->setItemDescription("Freeway Gold ");
// $requestedPackageLineItem->setItemDescriptionForClearance( "Pure Liquid herbal supplement for horses");
// $requestedPackageLineItem->setCustomerReferences($customerReferences)
// $requestedPackageLineItem->setSpecialServicesRequested($specialServicesRequested)
// $requestedPackageLineItem->setContentRecords($contentRecords)
// $requestedPackageLineItem->setConveyanceDetail($conveyanceDetail);
$requestedPackageLineItems[] = $requestedPackageLineItem ;
// $shipAddress->setGeographicCoordinates($geographicCoordinates);
$requestedShipment = new RequestedShipment();
$requestedShipment->setShipTimestamp("2021-02-25T12:34:56-06:00");
$requestedShipment->setDropoffType("REGULAR_PICKUP");
$requestedShipment->setServiceType('INTERNATIONAL_PRIORITY');
$requestedShipment->setPackagingType("FEDEX_TUBE");
// ->setVariationOptions($variationOptions)
$requestedShipment->setTotalWeight($weight);
// ->setTotalInsuredValue($totalInsuredValue)
$requestedShipment->setPreferredCurrency("GBP");
$requestedShipment->setShipmentAuthorizationDetail(
new ShipmentAuthorizationDetail(config("fedexconfig.uk.FEDEX_ACCOUNT_NUMBER"))
);
$requestedShipment->setShipper($shipParty);
$requestedShipment->setRecipient($recipParty);
// ->setRecipientLocationNumber($recipientLocationNumber)
$requestedShipment->setOrigin($contactAndAddress);
// ->setSoldTo($soldTo)
// ->setShippingChargesPayment($shippingChargesPayment)
// ->setSpecialServicesRequested($specialServicesRequested)
// ->setExpressFreightDetail($expressFreightDetail)
// ->setFreightShipmentDetail($freightShipmentDetail)
// ->setDeliveryInstructions($deliveryInstructions)
// ->setVariableHandlingChargeDetail($variableHandlingChargeDetail)
// ->setCustomsClearanceDetail($customsClearanceDetail)
// ->setPickupDetail($pickupDetail)
// ->setSmartPostDetail($smartPostDetail)
// ->setBlockInsightVisibility($blockInsightVisibility)
// ->setLabelSpecification($labelSpecification)
// ->setShippingDocumentSpecification($shippingDocumentSpecification)
$requestedShipment->setRateRequestTypes(["PREFERRED","LIST"]);
// ->setEdtRequestType($edtRequestType)
// ->setPackageCount($packageCount)
// ->setShipmentOnlyFields($shipmentOnlyFields)
// ->setConfigurationData($configurationData)
$requestedShipment->setRequestedPackageLineItems( $requestedPackageLineItems);
$rateRequest = new RateRequest(
$webAuthenticationDetail,
$clientDetail,
$versionId,
$transactionDetail,
$this->returnTransitAndCommit,
$this->carrierCodes,
[], /*variableOptions*/
$consolidationKey,
$requestedShipment
);
/**
* Minimal options
*/
$options = array(
\WsdlToPhp\PackageBase\AbstractSoapClientBase::WSDL_URL => '/var/www/vhosts/hiltonherbs.com/storage/app/public/_wsdl/RateService_v28.wsdl',
\WsdlToPhp\PackageBase\AbstractSoapClientBase::WSDL_CLASSMAP => ClassMap::get(),
// \WsdlToPhp\PackageBase\AbstractSoapClientBase::WSDL_LOCATION => "https://wsbeta.fedex.com:443/web-services/rate",
// \WsdlToPhp\PackageBase\AbstractSoapClientBase::WSDL_PASSPHRASE => config("fedexconfig.uk.FEDEX_KEY"),
// \WsdlToPhp\PackageBase\AbstractSoapClientBase::WSDL_PASSWORD => config("fedexconfig.uk.FEDEX_PASSWORD")
);
/**
* Samples for Get ServiceType
*/
$get = new Get($options);
/**
* Sample call for getRates operation/method
*/
if ($get->getRates(new \FedexRateService\StructType\RateRequest()) !== false) {
print_r($get->getResult());
} else {
print_r($get->getLastError());
}
dump($get->getStreamContext());
dump($get->getLastRequest(true));
// dump($get->getLastXml('xml'));
// $result = $get->get($parameters);
// dump($result);
// dump(
// $clientDetail,
// $webAuthenticationDetail,
// $versionId,
// $transactionDetail,
// $consolidationKey,
// $money,
// $shipmentAuthorizationDetail,
// $shipContact,
// $shipAddress,
// $recipParty,
// $contactAndAddress,
// $payment,
// new Dimensions(
// 14,
// 7,
// 26,
// "CM"
// ),
// $requestedPackageLineItems,
// $requestedShipment
// // $req
// );
// $req->getResult();
}
} getLastRequest <?xml version="1.0" encoding="UTF-8"?>\n
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://fedex.com/ws/rate/v28">\n
<SOAP-ENV:Header/>\n
<SOAP-ENV:Body>\n
<ns1:RateRequest>\n
<ns1:WebAuthenticationDetail/>\n
<ns1:ClientDetail/>\n
<ns1:Version/>\n
</ns1:RateRequest>\n
</SOAP-ENV:Body>\n
</SOAP-ENV:Envelope>\n getLastResponse <?xml version="1.0"?>\n
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">\n
<SOAP-ENV:Header/>\n
<SOAP-ENV:Body>\n
<v28:RateReply xmlns:v28="http://fedex.com/ws/rate/v28">\n
<v28:HighestSeverity xmlns:v28="http://fedex.com/ws/rate/v28">ERROR</v28:HighestSeverity>\n
<v28:Notifications xmlns:v28="http://fedex.com/ws/rate/v28">\n
<v28:Severity xmlns:v28="http://fedex.com/ws/rate/v28">ERROR</v28:Severity>\n
<v28:Source xmlns:v28="http://fedex.com/ws/rate/v28">prof</v28:Source>\n
<v28:Code xmlns:v28="http://fedex.com/ws/rate/v28">1000</v28:Code>\n
<v28:Message xmlns:v28="http://fedex.com/ws/rate/v28">Authentication Failed</v28:Message>\n
</v28:Notifications>\n
<v28:Version xmlns:v28="http://fedex.com/ws/rate/v28">\n
<v28:ServiceId xmlns:v28="http://fedex.com/ws/rate/v28"/>\n
<v28:Major xmlns:v28="http://fedex.com/ws/rate/v28"/>\n
<v28:Intermediate xmlns:v28="http://fedex.com/ws/rate/v28"/>\n
<v28:Minor xmlns:v28="http://fedex.com/ws/rate/v28"/>\n
</v28:Version>\n
</v28:RateReply>\n
</SOAP-ENV:Body>\n
</SOAP-ENV:Envelope>\n RateService_v28.wsdl |
Beta Was this translation helpful? Give feedback.
1 reply
-
You must add pay me a beer button. I feel in debit. |
Beta Was this translation helpful? Give feedback.
2 replies
-
I am so so sorry. Thanks. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Good evening to all,
I am sorry for this request but i am stack in my task because of
It look like i made some mistake when i send my request but i do not know how can i debug it.
I have got this steps for try to print out XML request.
https://github.com/WsdlToPhp/PackageEws365/blob/develop/generate.sh and copy classes from https://github.com/WsdlToPhp/PackageEws365/tree/develop/SoapClient, then you can do whatever you need in the https://github.com/WsdlToPhp/PackageEws365/blob/develop/SoapClient/SoapClient.php class that extends the native PHP SoapClient class.
but I am stack on the first
https://github.com/WsdlToPhp/PackageEws365/blob/develop/generate.sh
Beta Was this translation helpful? Give feedback.
All reactions