title: Integrating UPS Xml soap feed (PHP)
body: <p>I am trying to get the xml rate soap feed from UPS working.</p>
  
  <p>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).</p>
  
  <p>I took the example provided in the developers toolkit.  I tried everything =></p>
  
  <ul>
  <li>Change soap version to 1.2 </li>
  <li>Grab wsdl from remote url instead of on
  the disk </li>
  <li>I double checked the endpoint and userid, accesskey, pass,
  ...</li>
  </ul>
  
  <p>Does anyone have a working script ?, or even better can someone correct my mistake :)</p>
  
  <p>Code:</p>
  
  <pre><code>&lt;?php
  
  class UpsRate{
      private $access,$userid,$passwd,$wsdl,$operation,$endpointurl;
  
  
      public function  __construct() {
          $this-&gt;setConfig();
      }
  
      public function setConfig($is_test = true){
        $this-&gt;access = sfConfig::get('app_shipping_ups_access');
        $this-&gt;userid = sfConfig::get('app_shipping_ups_userid');
        $this-&gt;passwd = sfConfig::get('app_shipping_ups_password');
  
        $this-&gt;wsdl = sfConfig::get('sf_data_dir').'/wsdl/ups/RateWS.wsdl';
        $this-&gt;operation = "ProcessRate";
  
        $this-&gt;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-&gt;wsdl , array('soap_version' =&gt; 'SOAP_1_1','trace' =&gt; 1));
  
      //set endpoint url
      $client-&gt;__setLocation($this-&gt;endpointurl);
  
  
          //create soap header
          $usernameToken['Username'] = $this-&gt;userid;
          $usernameToken['Password'] = $this-&gt;passwd;
          $serviceAccessLicense['AccessLicenseNumber'] = $this-&gt;access;
          $upss['UsernameToken'] = $usernameToken;
          $upss['ServiceAccessToken'] = $serviceAccessLicense;
  
          $header = new SoapHeader('http://www.ups.com/XMLSchema/XOLTWS/UPSS/v1.0','UPSSecurity',$upss);
          $client-&gt;__setSoapHeaders($header);
  
  
          //get response
          return $client-&gt;__soapCall($this-&gt;operation ,array($this-&gt;processRate()));
        }
  
        catch(Exception $ex)
        {
            echo '&lt;pre&gt;';
            return print_r($client-&gt;__getLastResponse());
            echo '&lt;/pre&gt;';
        }
    }
  
  }
  
  
  
  ?&gt;
  </code></pre>