• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 288
  • Last Modified:

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.
0
namsu55
Asked:
namsu55
  • 2
  • 2
1 Solution
 
Aaron TomoskyTechnology ConsultantCommented:
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
0
 
namsu55Author Commented:
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));

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

	}

Open in new window

0
 
Aaron TomoskyTechnology ConsultantCommented:
I think you should look for a simple soap function that will return info or anything that you don't have to pass anything to. Like a version check or something. It will let you test connectivity. put that in your code before you call this addMember(). If it fails, change the address and try again. Then if success call this function.
0
 
namsu55Author Commented:
Good idea I will try that from the constructor.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now