Jump to content

I can't figure out what's wrong with this code.


antonb

Recommended Posts

When I run it I get an error saying: "Parse error: syntax error, unexpected '{' ...on line 56"

 

Then, when I get rid of the "{" I get this: "Parse error: syntax error, unexpected T_VARIABLE" ... on line 57"

 

Here is the code from the php file. If for some reason you need the whole thing let me know and I'll post it; "try" is line 55 and the curly bracket after it is line 56.

 

try 
{
    $response = $client->__soapCall("rateAvailableServices", array('parameters' => $request));
   
    if ($response->HighestSeverity != 'FAILURE' && $response->HighestSeverity != 'ERROR')
    {
        printRequestResponse($client);
    }
    else
    {
        echo 'Error in processing transaction.'. $newline. $newline; 
        foreach ($response-> Notifications as $notification)
        {
            if(is_array($response -> Notifications))
            {              
               echo $notification -> Severity;
               echo ': ';           
               echo $notification -> Message . $newline;
            }
            else
            {
                echo $notification . $newline;
            }
        }
    }

    writeToLog($client);    // Write to log file
    
} catch (SoapFault $exception) {
    printFault($exception, $client);
}

 

On an unrelated note, I can't seem to get the SOAP module working in my test environment. Grrrrrr. I working on my 1 and 1 space.  :-\

Link to comment
Share on other sites

Here is the whole thing with my dev. information taken out of it.

 

 

<?php

// Copyright 2008, FedEx Corporation. All rights reserved.
// Version 2.0.0

chdir('..'); 

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

$newline = "<br />";
$path_to_wsdl = "wsdl/RateAvailableServicesService_v2.wsdl";

ini_set("soap.wsdl_cache_enabled", "0"); 

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

$request['WebAuthenticationDetail'] = array('UserCredential' =>
                                      array('Key' => XXX', 'Password' => 'XXX')); // Replace 'XXX' and 'YYY' with FedEx provided credentials 
$request['ClientDetail'] = array('AccountNumber' => 'XXX', 'MeterNumber' => 'XXX');// Replace 'XXX' with your account and meter number
$request['TransactionDetail'] = array('CustomerTransactionId' => ' *** Rate Available Service Request v2 using PHP ***');
$request['Version'] = array('ServiceId' => 'crss', 'Major' => '2', 'Intermediate' => '0', Minor => '0');
$request['Origin'] = array('StreetLines' => array('Sender Address Line 1'), // Origin details
                                                           'City' => 'Sender City',
                                                           'StateOrProvinceCode' => 'TX',
                                                           'PostalCode' => '73301',
                                                           'CountryCode' => 'US');
$request['Destination'] = array('StreetLines' => array('Destination Address Line 1'), // Destination details
                                                                'City' => 'Recipient City',
                                                                'StateOrProvinceCode' => 'TN',
                                                                'PostalCode' => '38016',
                                                                'CountryCode' => 'US');
$request['CurrencyType'] = 'USD';
$request['DropoffType'] = 'REGULAR_PICKUP';  // valid codes BUSINESS_SERVICE_CENTER, DROP_BOX, REGULAR_PICKUP, REQUEST_COURIER and STATION
$request['CarrierCode'] = 'FDXE'; // valid codes FDXE-Express, FDXG-Ground, FDXC-Cargo, FXCC-Custom Critical and FXFR-Freight
$request['ServiceType'] = 'PRIORITY_OVERNIGHT'; // valid codes FIRST_OVERNIGHT, PRIORITY_OVERNIGHT, ...
$request['PackagingType'] = 'YOUR_PACKAGING'; // valid codes YOUR_PACKAGING, FEDEX_ENVELOPE, FEDEX_BOX, ...
$request['ShipDate'] = date('Y-m-d');
$request['RateRequestTypes'] = 'ACCOUNT'; // valid codes ACCOUNT and LIST
$request['RateRequestTypes'] = 'LIST'; // valid codes ACCOUNT and LIST
$request['RateRequestPackageSummary'] = array('PieceCount' => 1,
                                                                              'TotalWeight' => array('Value' => 20, 'Units' => 'LB'), // valid codes LB and KG
                                                                              'PerPieceDimensions' => array('Length' => 20, 'Width' => 20, 'Height' => 20, 'Units' => 'IN'), // valid code CM and IN
                                                                              'SpecialServicesRequested' => array('SpecialServiceTypes' => 'DANGEROUS_GOODS', // valid codes DANGEROUS_GOODS, APPOINTMENT_DELIVERY, ...
                                                                                                         'DangerousGoodsDetail' => array('Accessibility' => 'ACCESSIBLE'))); // valid codes ACCESSIBLE and INACCESSIBLE

try 
{
    $response = $client->__soapCall("rateAvailableServices", array('parameters' => $request));
   
    if ($response->HighestSeverity != 'FAILURE' && $response->HighestSeverity != 'ERROR')
    {
        printRequestResponse($client);
    }
    else
    {
        echo 'Error in processing transaction.'. $newline. $newline; 
        foreach ($response-> Notifications as $notification)
        {
            if(is_array($response -> Notifications))
            {              
               echo $notification -> Severity;
               echo ': ';           
               echo $notification -> Message . $newline;
            }
            else
            {
                echo $notification . $newline;
            }
        }
    }

    writeToLog($client);    // Write to log file
    
} catch (SoapFault $exception) {
    printFault($exception, $client);
}

?>

Link to comment
Share on other sites

found your error:

<?php

// Copyright 2008, FedEx Corporation. All rights reserved.
// Version 2.0.0

chdir('..'); 

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

$newline = "<br />";
$path_to_wsdl = "wsdl/RateAvailableServicesService_v2.wsdl";

ini_set("soap.wsdl_cache_enabled", "0"); 

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

$request['WebAuthenticationDetail'] = array('UserCredential' =>
                                      array('Key' => 'XXX', 'Password' => 'XXX')); // Replace 'XXX' and 'YYY' with FedEx provided credentials 
$request['ClientDetail'] = array('AccountNumber' => 'XXX', 'MeterNumber' => 'XXX');// Replace 'XXX' with your account and meter number
$request['TransactionDetail'] = array('CustomerTransactionId' => ' *** Rate Available Service Request v2 using PHP ***');
$request['Version'] = array('ServiceId' => 'crss', 'Major' => '2', 'Intermediate' => '0', Minor => '0');
$request['Origin'] = array('StreetLines' => array('Sender Address Line 1'), // Origin details
                                                           'City' => 'Sender City',
                                                           'StateOrProvinceCode' => 'TX',
                                                           'PostalCode' => '73301',
                                                           'CountryCode' => 'US');
$request['Destination'] = array('StreetLines' => array('Destination Address Line 1'), // Destination details
                                                                'City' => 'Recipient City',
                                                                'StateOrProvinceCode' => 'TN',
                                                                'PostalCode' => '38016',
                                                                'CountryCode' => 'US');
$request['CurrencyType'] = 'USD';
$request['DropoffType'] = 'REGULAR_PICKUP';  // valid codes BUSINESS_SERVICE_CENTER, DROP_BOX, REGULAR_PICKUP, REQUEST_COURIER and STATION
$request['CarrierCode'] = 'FDXE'; // valid codes FDXE-Express, FDXG-Ground, FDXC-Cargo, FXCC-Custom Critical and FXFR-Freight
$request['ServiceType'] = 'PRIORITY_OVERNIGHT'; // valid codes FIRST_OVERNIGHT, PRIORITY_OVERNIGHT, ...
$request['PackagingType'] = 'YOUR_PACKAGING'; // valid codes YOUR_PACKAGING, FEDEX_ENVELOPE, FEDEX_BOX, ...
$request['ShipDate'] = date('Y-m-d');
$request['RateRequestTypes'] = 'ACCOUNT'; // valid codes ACCOUNT and LIST
$request['RateRequestTypes'] = 'LIST'; // valid codes ACCOUNT and LIST
$request['RateRequestPackageSummary'] = array('PieceCount' => 1,
                                                                              'TotalWeight' => array('Value' => 20, 'Units' => 'LB'), // valid codes LB and KG
                                                                              'PerPieceDimensions' => array('Length' => 20, 'Width' => 20, 'Height' => 20, 'Units' => 'IN'), // valid code CM and IN
                                                                              'SpecialServicesRequested' => array('SpecialServiceTypes' => 'DANGEROUS_GOODS', // valid codes DANGEROUS_GOODS, APPOINTMENT_DELIVERY, ...
                                                                                                         'DangerousGoodsDetail' => array('Accessibility' => 'ACCESSIBLE'))); // valid codes ACCESSIBLE and INACCESSIBLE

try 
{
    $response = $client->__soapCall("rateAvailableServices", array('parameters' => $request));
   
    if ($response->HighestSeverity != 'FAILURE' && $response->HighestSeverity != 'ERROR')
    {
        printRequestResponse($client);
    }
    else
    {
        echo 'Error in processing transaction.'. $newline. $newline; 
        foreach ($response-> Notifications as $notification)
        {
            if(is_array($response -> Notifications))
            {              
               echo $notification -> Severity;
               echo ': ';           
               echo $notification -> Message . $newline;
            }
            else
            {
                echo $notification . $newline;
            }
        }
    }

    writeToLog($client);    // Write to log file
    
} catch (SoapFault $exception) {
    printFault($exception, $client);
}

?>

it was in one of your arrays.

Link to comment
Share on other sites

No, I am guessing he just accidentally removed that quote when putting in the XXXs.

 

Are you using PHP4? try/catch wasn't implemented until PHP5

 

I did accidentally delete that quote.

 

I need to check what version of PHP 1and1 is using.

 

I have version 5 going in my test environment but I can't get my SOAP module to work.

Link to comment
Share on other sites

Today I was able to get all of the kinks worked out of my code and sever so I am now able to send and receive using SOAP.

 

Now all I need to do is format the SOAP reply... can anyone point me in the right direction for this?

 

I only want to display a few of the returned fields; any suggestions are welcome.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.