EasyCFM.COM ColdFusion Forums / PHP to CFML / php to coldfusion conversion

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: php to coldfusion conversion

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

ajay
09-26-2007 @ 6:11 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 3
Joined: Sep 2007

Hey could anybady please help converting this php code to CF..this is about calling fedex webservices..i need to do this in coldfusion.. and i am new to php..


<?php

// Copyright 2007, FedEx Corporation. All rights reserved.

chdir('..');

require_once('library/fedex-common.php5');

$newline = "<br />";
ini_set("soap.wsdl_cache_enabled", "0");

$client = new SoapClient('wsdl/ServiceAvailabilityService.wsdl', array('trace' => 1)); // replace with valid path to WSDL

$request['ServiceAvailabilityRequest']['AuthenticationDetail'] = array('UserCredential' => 'XXX'); // Replace 'XXX' with FedEx provided user credential
$request['ServiceAvailabilityRequest']['ClientDetail'] = array('AccountNumber' => 'XXX', 'MeterNumber' => 'XXX');// Replace 'XXX' with your account and meter number
$request['ServiceAvailabilityRequest']['TransactionDetail'] = array('CustomerTransactionId' => ' *** Service Availability Request using PHP ***');
$request['ServiceAvailabilityRequest']['Origin'] = array('PostalCode' => '77510', // Origin details
                                                         'CountryCode' => 'US');
$request['ServiceAvailabilityRequest']['Destination'] = array('PostalCode' => '38110', // Destination details
                                                              'CountryCode' => 'US');
$request['ServiceAvailabilityRequest']['ShipDate'] = date('Y-m-d');
$request['ServiceAvailabilityRequest']['CarrierCode'] = 'FDXE'; // valid codes FDXE-Express, FDXG-Ground, FDXC-Cargo, FXCC-Custom Critical and FXFR-Freight
$request['ServiceAvailabilityRequest']['Service'] = 'PRIORITY_OVERNIGHT'; // valid code STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_GROUND, ...
$request['ServiceAvailabilityRequest']['Packaging'] = 'YOUR_PACKAGING'; // valid code FEDEX_BOK, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ...

try
{
    $response = $client ->__soapCall("serviceAvailability", array('parameters' => $request));

    if ($response -> ServiceAvailabilityReply -> HighestSeverity != 'FAILURE' && $response -> ServiceAvailabilityReply -> HighestSeverity != 'ERROR')
    {
        printRequestResponse($client);
    }
    else
    {
        echo 'Error in processing transaction.'. $newline. $newline;
        foreach ($response -> ServiceAvailabilityReply -> Notifications as $notification)
        {
            echo $notification . $newline;
        }
    }
    
    writeToLog($client);    // Write to log file  

} catch (SoapFault $exception) {
    printFault($exception, $client);
}

?>


Thanks in advance.


Website Designed and Developed by Pablo Varando.