tndono Posted May 18, 2007 Share Posted May 18, 2007 I've been having some fun. But I've gotten myself into a pickle. I was curious if anyone could help me out, please? I'm playing with a SOAP call to a web service that's not very well documented. It's taken me a couple of days to work out syntax and formatting, with little help from the web service provider. I can provide the code in its entirety. It is at the bottom of this post. The web service does not require a license key. My question is, how do I break out the result from the SOAP call into it's constituent elements to do further processing. I believe the result is a multidimensional array, as I can output the result using a print_r function. However, I can't figure out how to call the various elements of the array. Below is the output. Thanks, Tim Lookup by Address only: Array ( [0] => stdClass Object ( [intReturnCode] => 0 [strReturnShortDesc] => Address Found(City=MEDICINE LODGERslt=S5HPNTSCZA,Stat=10,-98.5870256x37.2779374) [strConfirmationNum] => 116409 [strEventTimeStamp] => 05/18/2007 14:21:15 [FIPSRecordList] => Array ( [0] => stdClass Object ( [intState] => 20 [strJurisdictionType] => STA [strCompositeSER] => MEDBA [intJurisdictionFIPS] => 20 [strGeneralTaxRateIntrastate] => 5.3 [strGeneralTaxRateInterstate] => 5.3 [strFoodDrugTaxRateIntrastate] => 5.3 [strFoodDrugTaxRateInterstate] => 5.3 ) [1] => stdClass Object ( [intState] => 20 [strJurisdictionType] => CTY [strCompositeSER] => MEDBA [intJurisdictionFIPS] => 7 [strGeneralTaxRateIntrastate] => 1 [strGeneralTaxRateInterstate] => 1 [strFoodDrugTaxRateIntrastate] => 1 [strFoodDrugTaxRateInterstate] => 1 ) [2] => stdClass Object ( [intState] => 20 [strJurisdictionType] => CIT [strCompositeSER] => MEDBA [intJurisdictionFIPS] => 45500 [strGeneralTaxRateIntrastate] => 0.75 [strGeneralTaxRateInterstate] => 0.75 [strFoodDrugTaxRateIntrastate] => 0.75 [strFoodDrugTaxRateInterstate] => 0.75 ) ) ) ) $ansa is an array: 1 And the code that generated the result follows: <?php $wskdor = "http://services.taxwatch.biz/rates/kansas/sstp.wsdl"; $client = new SoapClient($wskdor,array('trace' => 1)); $zip = 67104; $pluszip = 0000; $reqdate = "2007-05-17"; $address = "313 S. Iliff"; $addnum = "313"; $addst = "Iliff"; $adddir = Null; $addpredir = "S"; $addstsuf = Null; $city = "Medicine Lodge"; $state = "kansas"; $stateabbr = "ks"; // Call the GetFIPSByAddress method $ansa = array ($client->GetFIPSByAddress($addnum,$addpredir,$addst,$addstsuf,$adddir,$city,$zip,$pluszip,$reqdate)); print "<p>"; echo "<p>Lookup by Address only: <br>"; print_r($ansa); $yes = is_array($ansa); print "<p>\$ansa is an array: " . $yes; ?> Link to comment https://forums.phpfreaks.com/topic/52060-solved-dealing-with-soap-results/ Share on other sites More sharing options...
hitman6003 Posted May 18, 2007 Share Posted May 18, 2007 It's an object, not an array...I think...it's hard to tell...put the print_r result into a code block so it will preserve formatting. echo $result_object->intReturnCode; should result in "0" being echoed. Link to comment https://forums.phpfreaks.com/topic/52060-solved-dealing-with-soap-results/#findComment-256644 Share on other sites More sharing options...
tndono Posted May 18, 2007 Author Share Posted May 18, 2007 Being extremely new to php, not sure what you meant, but, I did this. echo $client->GetFIPSByAddress($addnum,$addpredir,$addst,$addstsuf,$adddir,$city,$zip,$pluszip,$reqdate); and got the following, where line 34 was the above line. Catchable fatal error: Object of class stdClass could not be converted to string in C:\Apache2\htdocs\kdor1.php on line 34 Link to comment https://forums.phpfreaks.com/topic/52060-solved-dealing-with-soap-results/#findComment-256646 Share on other sites More sharing options...
tndono Posted May 18, 2007 Author Share Posted May 18, 2007 Or, doing this. $ansa = $client->GetFIPSByAddress($addnum,$addpredir,$addst,$addstsuf,$adddir,$city,$zip,$pluszip,$reqdate); print_r( $ansa); produced the following results. stdClass Object ( [intReturnCode] => 0 [strReturnShortDesc] => Address Found(City=MEDICINE LODGERslt=S5HPNTSCZA,Stat=10,-98.5870256x37.2779374) [strConfirmationNum] => 116421 [strEventTimeStamp] => 05/18/2007 14:48:11 [FIPSRecordList] => Array ( [0] => stdClass Object ( [intState] => 20 [strJurisdictionType] => STA [strCompositeSER] => MEDBA [intJurisdictionFIPS] => 20 [strGeneralTaxRateIntrastate] => 5.3 [strGeneralTaxRateInterstate] => 5.3 [strFoodDrugTaxRateIntrastate] => 5.3 [strFoodDrugTaxRateInterstate] => 5.3 ) [1] => stdClass Object ( [intState] => 20 [strJurisdictionType] => CTY [strCompositeSER] => MEDBA [intJurisdictionFIPS] => 7 [strGeneralTaxRateIntrastate] => 1 [strGeneralTaxRateInterstate] => 1 [strFoodDrugTaxRateIntrastate] => 1 [strFoodDrugTaxRateInterstate] => 1 ) [2] => stdClass Object ( [intState] => 20 [strJurisdictionType] => CIT [strCompositeSER] => MEDBA [intJurisdictionFIPS] => 45500 [strGeneralTaxRateIntrastate] => 0.75 [strGeneralTaxRateInterstate] => 0.75 [strFoodDrugTaxRateIntrastate] => 0.75 [strFoodDrugTaxRateInterstate] => 0.75 ) ) ) Link to comment https://forums.phpfreaks.com/topic/52060-solved-dealing-with-soap-results/#findComment-256647 Share on other sites More sharing options...
hitman6003 Posted May 18, 2007 Share Posted May 18, 2007 you're calling a function, not echoing out a value in an object... $result = GetFIPSByAddress($addnum,$addpredir,$addst,$addstsuf,$adddir,$city,$zip,$pluszip,$reqdate); foreach ($result->FIPSRecordList as $record) { foreach ($record as $key => $value) { echo $key . " = " . $value . "<br />"; } } I think that should loop through them... Link to comment https://forums.phpfreaks.com/topic/52060-solved-dealing-with-soap-results/#findComment-256648 Share on other sites More sharing options...
tndono Posted May 18, 2007 Author Share Posted May 18, 2007 Most excellent. I had to make one small change to the first line, adding the instantiated SoapClient before the GetFPISByAddress method. Other than that, it works great. Thanks a bunch hitman6003, Oh Guru. $result = $client->GetFIPSByAddress($addnum,$addpredir,$addst,$addstsuf,$adddir,$city,$zip,$pluszip,$reqdate); foreach ($result->FIPSRecordList as $record) { foreach ($record as $key => $value) { echo $key . " = " . $value . "<br />"; } } Link to comment https://forums.phpfreaks.com/topic/52060-solved-dealing-with-soap-results/#findComment-256660 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.