namsu55
asked on
Trying alternative Soap Address if First Fails using standard PHP SOAP class
If I want to try another address if the first one fails, how would I go about doing this. I have exceptions in each of the web service functions I have wrapped. So if an error occurs that's related to the web service in terms of time out or not being found I would like to use the other address. I don't know how to go about this.
If the call Stack can be written as a function that takes the soap address as input you could just call the function with address1 and on fail, call it again with address2
ASKER
How would I do that. So for example look at my code.
In the catch what would you expect me to do, call a private function, which uses __setLocation?
I'm not too sure can you give me an example.
In the catch what would you expect me to do, call a private function, which uses __setLocation?
I'm not too sure can you give me an example.
public function addMember($memberArray){
$this->debugObj->output("addMember function START");
if (!is_array($memberArray)){
return "This is not an array. You require an array of all the details of the member you would like to add";
}
$this->debugObj->output("addMember function - Trying to add member details - " . print_r($memberArray, true));
try{
$AddMemberResponse = $this->_DNX->addMemberMethod(array('Security' => $this->_securityDetails, 'Member' => $memberArray));
} catch(SoapFault $fault){
return "Soap has an error. " . $fault;
} catch(Exception $error){
return $error;
}
$this->debugObj->output("addMember function - Response from addMemberMethod Web Service - " . print_r($AddMemberResponse, true));
if($this->success($AddMemberResponse->Code)){
$this->debugObj->output("addMember function - Successfully entered the member, response was a 1.");
return true;
} else {
$errorCode = $this->error_codes($AddMemberResponse->Code);
$this->debugObj->output("addMember function - Error code returned from web service, response was - " . $errorCode);
return $errorCode;
}
$this->debugObj->output("addMember function END");
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Good idea I will try that from the constructor.