We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


Trying alternative Soap Address if First Fails using standard PHP SOAP class

namsu55 asked
Medium Priority
Last Modified: 2012-05-11
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.
Watch Question

Aaron TomoskyDirector, SD-WAN Solutions

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


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.
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));


			$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));


			$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");


Open in new window

Director, SD-WAN Solutions
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview


Good idea I will try that from the constructor.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.