3

(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 WSDLs 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?

timborden
  • 1,470
  • 4
  • 18
  • 24
  • Did you use `->__getLastRequest()` method to see what gets sent across the wire? – Ja͢ck Aug 30 '12 at 13:45
  • @Jack Thanks for the response. It doesn't get to that point...the array doesn't validate with the WSDL. – timborden Aug 30 '12 at 14:28
  • Perhaps you should show us how you construct your dynamic array :) – Ja͢ck Aug 30 '12 at 14:33
  • @Jack - thanks for your interest....I've updated the question to include the class. – timborden Aug 30 '12 at 18:04
  • @Jack - I debugged it...but still don't understand the issue...in case your still curious, I clarified the issue above. Cheers. – timborden Aug 31 '12 at 14:53
  • congrats with the fix! but is this really the only thing that you changed? referencing issues usually only happen with objects and arrays are not the same thing, they get passed by reference but they have a copy-on-write mechanism to prevent unexpected issues .. I would file a bug report on this – Ja͢ck Aug 31 '12 at 15:49
  • @Jack...sorry, a bit of a novice on bug reporting...who do I file the report with? PHP? FedEx? – timborden Aug 31 '12 at 16:12
  • I doubt FedEx will be any help, so you can lodge your complaint on http://bugs.php.net - do a search for it first though, perhaps your PHP version makes a difference too – Ja͢ck Aug 31 '12 at 16:14

1 Answers1

0
$this->_fedex_request['RequestedShipment']['ShippingChargesPayment']['Payor']['ResponsibleParty'] = array(
'AccountNumber' => Kohana::$config->load('fedex.currency.'.$this->_from_currency.'.billAccount'),
'Contact' => array(
    'EMailAddress' => "name@domain.com",
),
);

It appears these two are not equal.

$this->_fedex_request['RequestedShipment']['CustomsClearanceDetail']['DutiesPayment']['Payor']['ResponsibleParty'] = Kohana::$config->load('fedex.currency.'.$this->_from_currency.'.billAccount'),
'Contact' => array(
    'EMailAddress' => "name@domain.com",
),
);

My guess is you mean to write

$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",
),
);
Kim E
  • 324
  • 2
  • 5