Integrating UPS Xml soap feed (PHP)

BrewDrutt

New Member
I am trying to get the xml rate soap feed from UPS working.Currently I am getting the error "Wrong version" (__Soapcall Exeption) or "0FailureHard10002The XML document is well formed but the document is not valid1" (Respons from server or php).I took the example provided in the developers toolkit. I tried everything =>
  • Change soap version to 1.2
  • Grab wsdl from remote url instead of onthe disk
  • I double checked the endpoint and userid, accesskey, pass,...
Does anyone have a working script ?, or even better can someone correct my mistake :)Code:\[code\]<?phpclass UpsRate{ private $access,$userid,$passwd,$wsdl,$operation,$endpointurl; public function __construct() { $this->setConfig(); } public function setConfig($is_test = true){ $this->access = sfConfig::get('app_shipping_ups_access'); $this->userid = sfConfig::get('app_shipping_ups_userid'); $this->passwd = sfConfig::get('app_shipping_ups_password'); $this->wsdl = sfConfig::get('sf_data_dir').'/wsdl/ups/RateWS.wsdl'; $this->operation = "ProcessRate"; $this->endpointurl = $is_test?'https://wwwcie.ups.com/ups.app/xml/Rate':'https://onlinetools.ups.com/ups.app/xml/Rate'; } private function processRate(){ //create soap request $option['RequestOption'] = 'Shop'; $request['Request'] = $option; $pickuptype['Code'] = '01'; $pickuptype['Description'] = 'Daily Pickup'; $request['PickupType'] = $pickuptype; $customerclassification['Code'] = '01'; $customerclassification['Description'] = 'Classfication'; $request['CustomerClassification'] = $customerclassification; $shipper['Name'] = 'Trutec'; $shipper['ShipperNumber'] = 'Y5562A'; $address['AddressLine'] = array ( 'Ter rivierenlaan 176', '', '' ); $address['City'] = 'Antwerp'; //$address['StateProvinceCode'] = 'MD'; $address['PostalCode'] = '2100'; $address['CountryCode'] = 'BE'; $shipper['Address'] = $address; $shipment['Shipper'] = $shipper; $shipto['Name'] = 'Imani Imaginarium'; $addressTo['AddressLine'] = '21 ARGONAUT SUITE B'; $addressTo['City'] = 'ALISO VIEJO'; //$addressTo['StateProvinceCode'] = 'CA'; $addressTo['PostalCode'] = '92656'; $addressTo['CountryCode'] = 'US'; $addressTo['ResidentialAddressIndicator'] = ''; $shipto['Address'] = $addressTo; $shipment['ShipTo'] = $shipto; $shipfrom['Name'] = 'Trutec'; $addressFrom['AddressLine'] = array ( 'Ter rivierenlaan 176', '', '' ); $addressFrom['City'] = 'Deurne'; //$addressFrom['StateProvinceCode'] = 'MD'; $addressFrom['PostalCode'] = '2100'; $addressFrom['CountryCode'] = 'BE'; $shipfrom['Address'] = $addressFrom; $shipment['ShipFrom'] = $shipfrom; $service['Code'] = '03'; $service['Description'] = 'Service Code'; $shipment['Service'] = $service; $packaging1['Code'] = '02'; $packaging1['Description'] = 'Rate'; $package1['PackagingType'] = $packaging1; $dunit1['Code'] = 'IN'; $dunit1['Description'] = 'cm'; $dimensions1['Length'] = '5'; $dimensions1['Width'] = '4'; $dimensions1['Height'] = '10'; $dimensions1['UnitOfMeasurement'] = $dunit1; $package1['Dimensions'] = $dimensions1; $punit1['Code'] = 'KG'; $punit1['Description'] = 'KG'; $packageweight1['Weight'] = '4'; $packageweight1['UnitOfMeasurement'] = $punit1; $package1['PackageWeight'] = $packageweight1; $shipment['Package'] = array( $package1 ); $shipment['ShipmentServiceOptions'] = ''; $shipment['LargePackageIndicator'] = ''; $request['Shipment'] = $shipment; return $request; } public function getRate(){ try { //nitialize soap client $client = new SoapClient($this->wsdl , array('soap_version' => 'SOAP_1_1','trace' => 1)); //set endpoint url $client->__setLocation($this->endpointurl); //create soap header $usernameToken['Username'] = $this->userid; $usernameToken['Password'] = $this->passwd; $serviceAccessLicense['AccessLicenseNumber'] = $this->access; $upss['UsernameToken'] = $usernameToken; $upss['ServiceAccessToken'] = $serviceAccessLicense; $header = new SoapHeader('http://www.ups.com/XMLSchema/XOLTWS/UPSS/v1.0','UPSSecurity',$upss); $client->__setSoapHeaders($header); //get response return $client->__soapCall($this->operation ,array($this->processRate())); } catch(Exception $ex) { echo '<pre>'; return print_r($client->__getLastResponse()); echo '</pre>'; } }}?>\[/code\]
 
Back
Top