(sorry if this sounds patronizing...I don't have a lot of code to paste, so I thought I'd be thorough with the description)
I'm using FedEx's SOAP
WSDL
s with PHP
's native SoapClient
.
The services RateService
, ShipService
, etc. have methods RateService->getRates(), ShipService->processShipment(), etc.
which accept an array as the argument.
I started off with "hard coded" arrays, and was able to validate the arrays via the WSDLs, connect to FedEx's server and get successful responses.
Here's the puzzling part.
I took my "hard coded" arrays and built a class around them, so that the array could be built "dynamically" (as you do).
When I ran the "dynamically created" arrays through the SoapClient, I got the following errors:
For rate requests
FedEx SoapFault error: Attribute not allowed (no wildcards allowed): id in element ShippingChargesPayment@http://fedex.com/ws/rate/v13
For ship requests
SOAP-ERROR: Encoding: Unresolved reference '#ref1'
It appears that the arrays aren't validating via the WSDLs.
UPDATE - I managed to debug the issue and get it working, but I'm not sure why it was an issue....here's the code and a further description...in case someone wants to explain why.
My shipment class starts with a private variable that contains a "blank" request array:
class Shipment {
private $_fedex_request = array(
...
"RequestedShipment" => array(
...
"ShippingChargesPayment" => array(
"PaymentType" => "SENDER",
"Payor" => array(
"ResponsibleParty" => array(
"AccountNumber" => null,
"Contact" => array(
"EMailAddress" => null,
),
),
),
),
"CustomsClearanceDetail" => array(
"DutiesPayment" => array(
"PaymentType" => "SENDER",
"Payor" => array(
"ResponsibleParty" => array(
"AccountNumber" => null,
"Contact" => array(
"EMailAddress" => null,
),
),
),
),
),
),
);
}
I have several methods that update the "blank" request, in one of the methods, I had this:
$ResponsibleParty = array(
'AccountNumber' => Kohana::$config->load('fedex.currency.'.$this->_from_currency.'.billAccount'),
'Contact' => array(
'EMailAddress' => "name@domain.com",
),
);
$this->_fedex_request['RequestedShipment']['ShippingChargesPayment']['Payor']['ResponsibleParty'] = $ResponsibleParty;
$this->_fedex_request['RequestedShipment']['CustomsClearanceDetail']['DutiesPayment']['Payor']['ResponsibleParty'] = $ResponsibleParty;
....that I changed to this:
$this->_fedex_request['RequestedShipment']['ShippingChargesPayment']['Payor']['ResponsibleParty'] = array(
'AccountNumber' => Kohana::$config->load('fedex.currency.'.$this->_from_currency.'.billAccount'),
'Contact' => array(
'EMailAddress' => "name@domain.com",
),
);
$this->_fedex_request['RequestedShipment']['CustomsClearanceDetail']['DutiesPayment']['Payor']['ResponsibleParty']= array(
'AccountNumber' => Kohana::$config->load('fedex.currency.'.$this->_from_currency.'.billAccount'),
'Contact' => array(
'EMailAddress' => "name@domain.com",
),
);
Is this a passing by reference issue?