Jump to content

Soap response object disappears


CaptainChainsaw

Recommended Posts

Hi all,

 

Would anyone be able to explain why I get a value in the variables "$redirecturl" and "$message" in the first example below but not in the second example?

 

As soon as the condition to check for success has been evaluated the object disappears:

 

if ($result->GetUnsecuredLenderResult->Success) {   // object disapepars after this line

 

 

 

Works in this example:

 


try {
$result = $client->GetUnsecuredLender(
$params
);

	$continueurl = trim($result->GetUnsecuredLenderResult->ContinueUrl);
                $responsetext = trim($result->GetUnsecuredLenderResult->ResponseText);
	if ($result->GetUnsecuredLenderResult->Success) { 
		$result = "A";
		$redirecturl = $continueurl; 
		$message = $responsetext;
	} else { // reject
		$result = "R";
		$redirecturl = $continueurl; 
		$message =  $responsetext; 

	}

} catch (Exception $e) {  // exception
	$result = "E";
	$redirecturl = "";
	$message = $e->getMessage();
}

 

 

Doesn't work in this example:

 


try {
$result = $client->GetUnsecuredLender(
$params
);

	if ($result->GetUnsecuredLenderResult->Success) { 
		$result = "A";
		$redirecturl = trim($result->GetUnsecuredLenderResult->ContinueUrl);
		$message =  trim($result->GetUnsecuredLenderResult->ResponseText);
	} else { // reject
		$result = "R";
		$redirecturl = trim($result->GetUnsecuredLenderResult->ContinueUrl);
		$message =  trim($result->GetUnsecuredLenderResult->ResponseText);

	}

} catch (Exception $e) {  // exception
	$result = "E";
	$redirecturl = "";
	$message = $e->getMessage();
}

 

 

Any advice on this would be appreciated as always.

 

Cheers,

 

CaptainChainsaw

Link to comment
https://forums.phpfreaks.com/topic/267738-soap-response-object-disappears/
Share on other sites

You overwrite the object:

 

if ($result->GetUnsecuredLenderResult->Success) {  // $result === object
		$result = "A"; // $result === string

 

PHP is dynamic typed which means that it's type is defined by whatever you assign it.

http://php.net/manual/en/language.types.type-juggling.php

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.