1) ); $nl = "
\n"; echo "\n----------------------\n"; echo "
\nStarting Soap Test Script
\n"; function getToken($client) { //change this to your relevant information $username = 'username@parcelperfect.com'; $password = 'password'; $salt = ''; $params = array( "s_email" => $username, ); //Get Salt and MD5 Hash it $result = $client->__soapCall("Auth_getSalt", array($params)); // A mistake has been made with the submission if($result->errorcode != 0) { echo $result->errormessage."
"; } else { // Extract and process the salt for secureToken usage $salt = $result->results[0]; echo "
\nSalt:
\n"; print_r($salt); $password_crypt = md5($password.$salt->salt); echo "
\nCrypted Password: ".$password_crypt."
\n"; } //Get Token if(isset($password_crypt) && $password_crypt != '') { $params = array( "s_email" => $username, "s_password" => $password_crypt ); $result = $client->__soapCall("Auth_getSecureToken", array($params)); // A mistake has been made with the submission if($result->errorcode != 0) { echo $result->errormessage."
\n"; } else { // Extract and process the tokenid for compound_collection_params's usage $token = $result->results[0]; $token_id = $token->token_id; echo "
\nSecureToken: ".$token_id."
\n"; return $token_id; } } } function submitCompoundCollection($client, $token_id) { echo "
\nSubmitting Compound Collection
\n"; // All the waybills being submitted uses the below // information for a full waybill submission // The collection's details are below: $collection_details = array( "i_collectno" => 6452, "s_accnum" => "PPOT", "s_collectiondate" => "18.01.2018", "s_origpers" => "Orig Person", "s_origperadd1" => "6 Main Road", "s_origperadd2" => "Claremont", "s_origperadd3" => "Cape town", "s_origperadd4" => "Western Cape", "i_origplace" => 4969, "s_origtown" => "CLAREMONT Cape Town", "s_origperpcode" => "7700", "s_origpercontact" => "A Person", "s_origperphone" => "0217625454", "s_origperphone2" => "", "s_origpercell" => "0785555555", "f_origlatitude" => 34.12345, "f_origlongitude" => 32.12345, "s_starttime" => "08:00", "s_endtime" => "16:30", "s_notes" => "waybill notes", "f_weight" => 1.58, "i_pieces" => 1 ); // define the first waybill now, we add it to the entire call later // destplace, desttown, destpers, destpercontact, destperpcode inputs are mandatory $first_waybill = array( "details" => array( "s_waybill" => "COMPCOLWAY1", "s_waydate" => "11.01.2018", "s_service" => "ONX", "s_destperadd1" => "11 Lansdowne Road", "s_destperadd2" => "Claremont", "s_destperadd3" => "Cape Town", "s_destperadd4" => "Western Cape", "i_destplace" => 5437, "s_destperpcode" => "", "s_desttown" => "CLAREMONT (Cape Town)", "s_destpers" => "Dest person", "s_destpercontact" => "A Person", "s_destperphone" => "0217625454", "s_destperphone2" => "", "s_destpercell" => "0785555555", "s_destperemail" => "example@email.com", "s_duedate" => "20.01.2018", "i_notifydestpers" => 0, "s_specinstruction" => "instruction", "s_reference" => "waybill reference", "i_insuranceflag"=> 1, "i_instype"=> 1, "f_declaredvalue"=> 58.59, "i_nondoxflag"=> 0, "s_currency"=>"ZAR", "f_customsvalue"=> 58.59, "i_surchargeflag1"=> 1, "i_surchargeflag2"=> 0, "i_surchargeflag3"=> 0, "i_surchargeflag4"=> 0, "i_surchargeflag5"=> 0, "i_surchargeflag6"=> 0, "i_surchargeflag7"=> 0, "i_surchargeflag8"=> 0, "i_surchargeflag9"=> 0 ), "contents" => array( 0 => array( "i_item"=> 1, "i_pieces"=> 1, "s_description"=> "contentsDesc", "f_actmass"=> 2.5, "i_dim1"=> 10, "i_dim2"=> 15, "i_dim3"=> 20, "i_defitem"=> 1 ) ), "tracks" => array( 0 => array( "s_trackno"=> "COMPCOLWAY10001", "i_parcelno"=> 1, "i_item"=> 1 ) ), "wayrefs" => array( 0 => array( "s_reference"=> "REFERENCE112", "i_pageno"=> 1 ) ) ); // define the second waybill now, we add it to the entire call later // desttown, destpers, destpercontact, destperpcode inputs are mandatory $second_waybill = array( "details" => array( "s_waybill" => "COMPCOLWAY2", "s_waydate" => "11.01.2018", "s_service" => "ONX", "s_destperadd1" => "11 Lansdowne Road", "s_destperadd2" => "Claremont", "s_destperadd3" => "Cape Town", "s_destperadd4" => "Western Cape", "i_destplace" => 5437, "s_destperpcode" => "", "s_desttown" => "CLAREMONT (Cape Town)", "s_destpers" => "Dest person", "s_destpercontact" => "A Person", "s_destperphone" => "0217625454", "s_destperphone2" => "", "s_destpercell" => "0785555555", "s_destperemail" => "example@email.com", "s_duedate" => "20.01.2018", "i_notifydestpers" => 0, "s_specinstruction" => "instruction", "s_reference" => "waybill reference", "i_insuranceflag"=> 1, "i_instype"=> 1, "f_declaredvalue"=> 58.59, "i_nondoxflag"=> 0, "s_currency"=>"ZAR", "f_customsvalue"=> 58.59, "i_surchargeflag1"=> 1, "i_surchargeflag2"=> 0, "i_surchargeflag3"=> 0, "i_surchargeflag4"=> 0, "i_surchargeflag5"=> 0, "i_surchargeflag6"=> 0, "i_surchargeflag7"=> 0, "i_surchargeflag8"=> 0, "i_surchargeflag9"=> 0 ), "contents" => array( 0 => array( "i_item"=> 1, "i_pieces"=> 1, "s_description"=> "contentsDesc", "f_actmass"=> 1.5, "i_dim1"=> 10, "i_dim2"=> 15, "i_dim3"=> 20, "i_defitem"=> 1 ) ), "tracks" => array( 0 => array( "s_trackno"=> "COMPCOLWAY20001", "i_parcelno"=> 1, "i_item"=> 1 ) ), "wayrefs" => array( 0 => array( "s_reference"=> "REFERENCE112", "i_pageno"=> 1 ) ) ); // Put all the paramaters together $compound_collection_params = array ( "details" => $collection_details, "waybills" => array( $first_waybill, $second_waybill ) ); // Finally make the call to the webservice $result = $client->__soapCall ( "Collection_submitCompoundCollection", array( $token_id, $compound_collection_params ) ); // Check for and output any errors with submission if($result->errorcode != 0) { echo $result->errormessage."
"; } else { echo "
\nSubmit Compound Collection Request Result:
\n"; print_r($result); } } // Call the above methods to get a Token and submit a compound collection. $token_id = getToken($client); submitCompoundCollection($client, $token_id); echo "Script finished"; echo "
\n----------------------
\n"; ?>