Link to home
Start Free TrialLog in
Avatar of karthik80c
karthik80cFlag for United States of America

asked on

In the ABN webservice, need to get the ABN/ACN number using name search.

I used the below code for search by name. But it returns an error.
PHP Fatal error:  Call to undefined method stdClass::externalNameSearch() in /home/kaybsoln/public_html/kaybs.in/PHPSample/abnlookup.class.php on line 43

<?php


/**
 * @author Justin Swan - 16 August 2012
 * extends php soap client to utilize the Australian Government ABN Lookup web service 
 * requires php 5 or greater with lib-xml enabled/compiled in Apache, see the PHP manual for further requirements info
 * 
 * @link    http://www.php.net/manual/en/book.soap.php
 * @link    http://abr.business.gov.au/Webservices.aspx
 * 
 * @param string $guid - get a guid id by registering @ http://abr.business.gov.au/Webservices.aspx
 * 
 */
 
class abnlookup extends SoapClient{
 
    private $guid = "******************************"; 
 
    public function __construct($guid)
    {
        $this->guid = $guid;
        $params = array(
            'soap_version' => SOAP_1_1,
            'exceptions' => true,
            'trace' => 1,
            'cache_wsdl' => WSDL_CACHE_NONE
        ); 
 
        parent::__construct('http://abr.business.gov.au/abrxmlsearch/ABRXMLSearch.asmx?WSDL', $params);
    }
 
   public function searchByAbn($abn, $historical = 'N'){
		$params = new stdClass();
		$params->searchString				= $abn;
		$params->includeHistoricalDetails	= $historical;
		$params->authenticationGuid			= $this->guid;
		return $this->ABRSearchByABN($params);
	}

  public function searchByName($company_name){
        $params = new stdClass();
        $params->externalNameSearch($company_name);
        $params->authenticationGuid            = $this->guid;
        return $this->ABRSearchByName($params);
    }
 } 
$company_name = "A. & G. PTY LTD";
$abn_search_string = "74599608295"; // you can assign your post/get var or abn string here


try{
    $abnlookup = new abnlookup($abn_guid);
    try{
        $result = $abnlookup->searchByName($company_name); 
 
        // display all results
        echo "<pre>";
        print_r($result);
        echo "</pre>";
 
        // also display by variables using object notation.
        echo "<pre>";
        $result->ABRPayloadSearchResults->response;
        echo "</pre>";
 
    } catch    (Exception $e){
        throw $e;
    }
 
} catch(Exception $e){
    echo $e->getMessage();
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial