dfowler Posted October 27, 2008 Share Posted October 27, 2008 Hey guys, I've been looking for help with pear::soap for the last couple of days and haven't gotten a lot of responses. I've been able to solve a lot of my problems (slowly but surely), but thought I would again try to get some help. My current problem is that a response I am getting is using attributes. For example: <account id="123523" name="Bob" /> Instead of the typical: <account> <id>1234523</id> <name>Bob</name> </account> I can't figure out how to read these attributes that I need. When I get the response I try using print_r($response); but am only getting the following: stdClass Object ( [Result] => [Account] => stdClass Object ( ) ) Does anybody have an idea how to read these attributes? Or at least get the raw xml that is sent back? Thanks for any help. Link to comment https://forums.phpfreaks.com/topic/130311-soap-problem-using-pear/ Share on other sites More sharing options...
dfowler Posted October 27, 2008 Author Share Posted October 27, 2008 I found a call for getLastResponse(), but that doesn't appear to work. So I'm still clueless on how to get the information I need. Link to comment https://forums.phpfreaks.com/topic/130311-soap-problem-using-pear/#findComment-675984 Share on other sites More sharing options...
Fruct0se Posted October 27, 2008 Share Posted October 27, 2008 I am assuming you are using some sort of API, who are you sending the headers to? Link to comment https://forums.phpfreaks.com/topic/130311-soap-problem-using-pear/#findComment-675988 Share on other sites More sharing options...
dfowler Posted October 28, 2008 Author Share Posted October 28, 2008 Yes, but it seems that web services are brand new. So they don't have a full API generated for this. Also, they don't have ANYBODY who knows or uses PHP. So I am having to code all this on my own. Here is my full code so far: <?php require_once "SOAP/Client.php"; include "connect.php"; include "country_conv.php"; $countryUpper = strtoupper($_POST['billTo_country']); $wsdl_url = $url; $WSDL = new SOAP_WSDL($wsdl_url); $client = $WSDL->getProxy(); $params = array( 'WebId' => $webID, 'Password' => $webPW, 'EmployeeLogin' => $empLogin, 'EmployeePassword' => $empPW, ); $response = $client->SecurityValidateEmployeeLogon($params); if (PEAR::isError($response)) { echo "<br>An error #" . $response->getCode() . " occurred!<br>"; echo " Error: " . $response->getMessage() . "<br>\n"; exit(); } else { $empToken = $response->Token; $firstName = $_POST['billTo_firstName']; $lastName = $_POST['billTo_lastName']; $randNum = rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9) . rand(0,9); $compName = $firstName." ".$lastName." (".$randNum.")"; $header = new SOAP_Header('{'. Conferencing . '}HeaderToken', NULL, array('Token' => $empToken), 0); $params = array( 'Company' => array( 'Name' => $compName, 'Address' => array( 'Address1' => $_POST['billTo_street1'], 'Address2' => $_POST['billTo_street2'], 'City' => $_POST['billTo_city'], 'State' => $_POST['billTo_state'], 'Zip' => $_POST['billTo_postalCode'], 'Country' => $country[$countryUpper] ), 'BlastEmailAllowed' => 'false', 'Enterprise' => $enterprise, 'Provider' => $provider ) ); $client->addHeader($header); $response = $client->ProvisioningCompanyCreate($params); if (PEAR::isError($response)) { echo "<br>An error #" . $response->getCode() . " occurred!<br>"; echo " Error: " . $response->getMessage() . "<br>\n"; exit(); } else { $compID = $response->CompanyId; $header = new SOAP_Header('{'. Conferencing . '}HeaderToken', NULL, array('Token' => $empToken), 0); $account_info = array( 'CompanyID' => $compID, 'TimeZone' => 'ESTRN-BASE', 'ViewCompanyWebReport' => 'true' ); $contact_info = array( 'FirstName' => $firstName, 'LastName' => $lastName, 'Company' => $_POST['billTo_company'], 'Phone' => $_POST['billTo_phoneNumber'], 'Email' => $_POST['billTo_email'], 'Address1' => $_POST['billTo_street1'], 'Address2' => $_POST['billTo_street2'], 'City' => $_POST['billTo_city'], 'State' => $_POST['billTo_state'], 'Zip' => $_POST['billTo_postalCode'], 'Country' => $country[$countryUpper] ); $contact_value = new SOAP_VALUE('{'. Conferencing . '}ContactInfo', false, NULL, $contact_info); $account_value = new SOAP_VALUE('{'. Conferencing . '}Account', false, $contact_value, $account_info); $params = array( $account_value ); $client->addHeader($header); $response = $client->CreateAccount($params); print_r($response); } } ?> Link to comment https://forums.phpfreaks.com/topic/130311-soap-problem-using-pear/#findComment-676582 Share on other sites More sharing options...
dfowler Posted October 29, 2008 Author Share Posted October 29, 2008 Anybody know how to read attributes? Link to comment https://forums.phpfreaks.com/topic/130311-soap-problem-using-pear/#findComment-677456 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.