Getting Started Blank Results

Forum for users and developers of Bullhorn's Webservices API suite

Moderators: StaffingSupport, s.emmons, BullhornSupport

Post Reply
webdeveloper8
User
Posts: 17
Joined: Wed Dec 31, 1969 8:00 pm

Getting Started Blank Results

Post by webdeveloper8 » Mon Apr 30, 2012 1:10 pm

To get started with the Web Services I uploaded the GettingStartedWtihWebServices_Solution.php example file and I entered in my username, password and API key. And I get no results at all. I don't get any errors, but no results and I was expecting to get my clients data.

Here is the code that I am using.

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Getting Started with Web Services</title>
</head>
    <body>
    <?php
		// Create a new instance of the SoapClient class.
		$params = array(
			'trace' => 1,
			'soap_version' => SOAP_1_1);
		$BHclient = new SoapClient("https://api.bullhornstaffing.com/webservices-1.1/?wsdl",$params);
		
		// To run this code, you will need a valid username, password, and API key.
		$username = "xxx";
		$password = "xxx";
		$apiKey = "xxx";

		// Start a new session
		$session_request = new stdClass();
		$session_request->username = $username;
		$session_request->password = $password;
		$session_request->apiKey = $apiKey;
		$API_session = $BHclient->startSession($session_request);
		$API_currentSession = $API_session->return;
		
		// Create an array with the query parameters
		$query_array = array(
		'entityName' => 'Candidate',
		'maxResults' => 10,
		'parameters' => array()
		);
		
		// Create the DTO type that the API will understand by casting the array to the dtoQuery
		// type that the query operation expects. 
		$SOAP_query = new SoapVar($query_array, SOAP_ENC_OBJECT,"dtoQuery", "http://query.apiservice.bullhorn.com/");
		
		// Put the DTO into a request object
		$request_array = array (
		'session' => $API_currentSession,
		'query' => $SOAP_query);
		
		// Cast the request as a query type
		$SOAP_request = new SoapVar($request_array, SOAP_ENC_OBJECT, "query", "http://query.apiservice.bullhorn.com/");
		
		// Use the query method to return the candidate ids
		try {
		$queryResult = $BHclient->query($SOAP_request);
		} catch (SoapFault $fault) {
		var_dump($BHclient->__getLastRequest());
		die($fault->faultstring);
		}
		
		// Use the find() method to retrieve the candidate DTO for each Id
		// Loop through each Id in the query result list
		foreach ($queryResult->return->ids as $value){
			// Cast each Id to an integer type
			$findId = new SoapVar($value, XSD_INTEGER,"int","http://www.w3.org/2001/XMLSchema");
			// Create the find() method request
			$find_request = array(
				'session' => $API_currentSession,
				'entityName' => 'Candidate',
				'id' => $findId
			);
			// Use the find() method to return the candidate dto
			try {
			$findResult = $BHclient->find($find_request);
			} catch (SoapFault $fault) {
			var_dump($BHclient->__getLastRequest());
			die($fault->faultstring);
			}
			
			// Print fields from the dto object
			/*
			print "\nCandidate name: ".$findResult->return->dto->name;
			print "\nOccupation: ".$findResult->return->dto->occupation;
			print "\nStatus: ".$findResult->return->dto->status;
			print "\n";
			*/
		}
		
		// Use the findMultiple() method to retrieve the candidate DTO for each Id
		// Create an array containing each Id in the query result list
		$findId_array =  array();
		foreach ($queryResult->return->ids as $value){
			// Cast each Id to an integer type
			$findId = new SoapVar($value, XSD_INTEGER,"int","http://www.w3.org/2001/XMLSchema");
			$findId_array[] = $findId;
		}
		
		// Create the findMultiple() method request
		$find_request = array(
			'session' => $API_currentSession,
			'entityName' => 'Candidate',
			'ids' => $findId_array
		);
			
		// Use the findMultiple method to return the candidate dtos
		try {
		$findResult = $BHclient->findMultiple($find_request);
		} catch (SoapFault $fault) {
		var_dump($BHclient->__getLastRequest());
		die($fault->faultstring);
		}
	?>
		
	<!--   Create a table with the Candidate Ids -->
	<table border="1" cellspacing="2" cellpadding="2">
	<tr>
		<th>Candidate Id</th>
	</tr>
	
	<?php foreach($queryResult->return->ids as $value):?>
	<tr style="text-align:center">
		<td><?php echo $value;?></td>
	</tr>
	<?php endforeach?>
	</table>
	
	<!--   Create a table with the Candidate DTO information -->
	<br/>
	<table border="1" cellspacing="2" cellpadding="2">
	<tr>
		<th>Name</th>
		<th>Occupation</th>
		<th>Status</th>
	</tr>
	
	<?php foreach($findResult->return->dtos as $value):?>
	<tr>
		<td><?php echo $value->name; ?></td>
		<td><?php echo $value->occupation; ?></td>
		<td><?php echo $value->status; ?></td>
	</tr>
	<?php endforeach?>
	</table>

    </body>
</html>
Thanks.

MGIORDANO1
User
Posts: 13
Joined: Thu Apr 19, 2012 8:47 am

Re: Getting Started Blank Results

Post by MGIORDANO1 » Tue May 01, 2012 1:59 pm

Hello

The getting started page is a guide to allow you to start your queries. What information are you trying to query on this page after you enter the username,password,API key information?

Thank you

webdeveloper8
User
Posts: 17
Joined: Wed Dec 31, 1969 8:00 pm

Re: Getting Started Blank Results

Post by webdeveloper8 » Tue May 01, 2012 2:30 pm

Code: Select all

// Create an array with the query parameters
      $query_array = array(
      'entityName' => 'Candidate',
      'maxResults' => 10,
      'parameters' => array()
      );
should that query and the following php return a table with those values?

Code: Select all

<!--   Create a table with the Candidate Ids -->
   <table border="1" cellspacing="2" cellpadding="2">
   <tr>
      <th>Candidate Id</th>
   </tr>
   
   <?php foreach($queryResult->return->ids as $value):?>
   <tr style="text-align:center">
      <td><?php echo $value;?></td>
   </tr>
   <?php endforeach?>
   </table>
   
   <!--   Create a table with the Candidate DTO information -->
   <br/>
   <table border="1" cellspacing="2" cellpadding="2">
   <tr>
      <th>Name</th>
      <th>Occupation</th>
      <th>Status</th>
   </tr>
   
   <?php foreach($findResult->return->dtos as $value):?>
   <tr>
      <td><?php echo $value->name; ?></td>
      <td><?php echo $value->occupation; ?></td>
      <td><?php echo $value->status; ?></td>
   </tr>
   <?php endforeach?>
   </table>

MGIORDANO1
User
Posts: 13
Joined: Thu Apr 19, 2012 8:47 am

Re: Getting Started Blank Results

Post by MGIORDANO1 » Wed May 02, 2012 12:09 pm

Can you try the following sample with your username/password/API Key?

Code: Select all

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
	
<?php
$params = array('trace' => 1,
		'soap_version' => SOAP_1_1);
		$BHclient = new SoapClient("https://api.bullhornstaffing.com/webservices-2.0/?wsdl",$params);
		
// To run this code, you will need a valid username, password, and API key.
$username = "[DELETED]";
$password = "[DELETED]";
$apiKey = "[DELETED]";

// Start a new session
$session_request = new stdClass();
$session_request->username = $username;
$session_request->password = $password;
$session_request->apiKey = $apiKey;
$API_session = $BHclient->startSession($session_request);
$API_currentSession = $API_session->return->session;

//query that looks up the ids
$query_array = array(
  'entityName'  => 'Candidate',
  'maxResults'  => '10',
  'distinct' => 'FALSE',
  'where'  => 'address.countryID = 1',
  'parameters'  => array()
);

$request_array = array (
  'session'  => $API_currentSession, 
  'query'  => $query_array
 );
 
 // running query
try{ 
  $queryResult = $BHclient->query($request_array); 
  } catch  (SoapFault $fault) { 
     echo $BHclient->__getLastResult(); 
     die($fault->faultstring); 
  }
  // echo session to see if valid
  echo "Session: ".$queryResult->return->session."</br>";
  
  //For Printing results
  if (count($queryResult->return->ids) == 0)
	echo "No results";
  else
	print_r($queryResult->return->ids);
	
	//For storing values as a string
	echo "We got here";
	 $string = (array) $queryResult->return->ids;
	 print_r( $string );

?>

webdeveloper8
User
Posts: 17
Joined: Wed Dec 31, 1969 8:00 pm

Re: Getting Started Blank Results

Post by webdeveloper8 » Wed May 02, 2012 12:20 pm

tried and there is nothing, here is the result

http://www.citynatl.com/wordpress/wp-co ... lution.php

MGIORDANO1
User
Posts: 13
Joined: Thu Apr 19, 2012 8:47 am

Re: Getting Started Blank Results

Post by MGIORDANO1 » Wed May 02, 2012 1:07 pm

We are able to run the code on our end. I am including a screenshot of the result and the result from SOAPUI for your company. I would reccomend downloading the free version of SOAPUI and using the WSDL from the developer.bullhorn.com documentation.
Attachments
exampleSOAP.PNG
exampleSOAP.PNG (190.9 KiB) Viewed 12972 times
example.PNG
example.PNG (198.72 KiB) Viewed 12973 times

webdeveloper8
User
Posts: 17
Joined: Wed Dec 31, 1969 8:00 pm

Re: Getting Started Blank Results

Post by webdeveloper8 » Wed May 02, 2012 1:15 pm

Forgive me, and I'll be honest, for not really understanding what is going on here. I am not trying to test the code using soap. I am trying to display City and National Employments data for Candidates and Job Listings on their new website. It would be my understanding that I would try to use the sample code found in "http://developer.bullhorn.com/Getting_S ... es_and_PHP" to try and get the information to display on their website.

Is it possible for me to do this? Am I just looking in the wrong place for code?

We have published a couple of their jobs to their career portal but they would like to use the website to list these results and not the career portal.

webdeveloper8
User
Posts: 17
Joined: Wed Dec 31, 1969 8:00 pm

Re: Getting Started Blank Results

Post by webdeveloper8 » Wed May 02, 2012 1:27 pm

http://www.talonpro.com/search-jobs.php

Is an example of a website that is doing what I am interested in doing.

MGIORDANO1
User
Posts: 13
Joined: Thu Apr 19, 2012 8:47 am

Re: Getting Started Blank Results

Post by MGIORDANO1 » Wed May 02, 2012 2:26 pm

Hello


The screenshots posted show that information is able to be retrieved. Each coding environment is different; we do not provide specific support to each coding environment or how to write the code. We have sample code to provide a high level reference however the end user must troubleshoot any issues if it does not work in his or her environment.


Thank you

webdeveloper8
User
Posts: 17
Joined: Wed Dec 31, 1969 8:00 pm

Re: Getting Started Blank Results

Post by webdeveloper8 » Thu May 03, 2012 4:49 pm

As soon as I add this line of php to any page it breaks the page and doesnt display anything below it, be it php or just plain html.

$BHclient = new SoapClient("https://api.bullhornstaffing.com/webser ... l",$params);

I am following http://developer.bullhorn.com/Getting_S ... es_and_PHP step by step and I have the correct username, password, and apikey but that line breaks the page.

I have verified that the SOAP Client is enabled on my server as well.

webdeveloper8
User
Posts: 17
Joined: Wed Dec 31, 1969 8:00 pm

Re: Getting Started Blank Results

Post by webdeveloper8 » Thu May 03, 2012 5:13 pm

Fatal error: Uncaught SoapFault exception: [S:Server] Require username, password, and api key. in /home/hoppes/public_html/api/index.php:19 Stack trace: #0 /home/hoppes/public_html/api/index.php(19): SoapClient->__call('startSession', Array) #1 /home/hoppes/public_html/api/index.php(19): SoapClient->startSession(Object(stdClass)) #2 {main} thrown in /home/hoppes/public_html/api/index.php on line 19

mean anything to anyone?

MGIORDANO1
User
Posts: 13
Joined: Thu Apr 19, 2012 8:47 am

Re: Getting Started Blank Results

Post by MGIORDANO1 » Fri May 11, 2012 10:27 am

Hello

Usually when this error occurs the fix is to enable secure wrappers in your environment for the code to work.
As for the credentials error it appears that the code is not able to read the credentials you are entering.

Thank you

Post Reply