Category Association Is not inserted in Bullhorn

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

Moderators: StaffingSupport, s.emmons, BullhornSupport

Post Reply
techteam321
User
Posts: 4
Joined: Sat Jun 23, 2012 7:37 am

Category Association Is not inserted in Bullhorn

Post by techteam321 » Thu Sep 13, 2012 5:40 am

Hi,

I am using php for inserting candidate details in bullhorn and I am using bullhorn process for the first time. I can insert the candidate details without any issue, after inserting the candidate details I try to associate category and skills for the candidate inserted but I cannot do so.

I tried the coding in http://developer.bullhorn.com/Working_with_Candidates for associating category and skills. Could you please help me over it.

I could not trace out the issue because of null value returning. Below is my code for association the values in the bullhorn.

$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;


/* To make the username unique, use the first initial and last name with a random number. You can use any mechanism for generating the random number. */
$random_num = rand(1000,9999);
$sql=mysql_query("select * from candidate where id=29");

$value=mysql_fetch_array($sql);
$name = $value['first_name'] ." ".$value['last_name'];

$location1 = explode('~',$value['locations_intrested_in']);
$location = implode(',',$location1);
$sel = "select * from location where id IN (".$location.")";
$chkresult = mysql_query($sel);
$chkarray = '';
while($chkvalue = mysql_fetch_array($chkresult)){
$chkarray[] = $chkvalue['location'];
}
$ch_location = implode(',',$chkarray);

$sql = "select county from county where visible=1 and id='".$value['county']."'";
$resultset = mysql_query($sql);
if(mysql_num_rows($resultset)>0) {
$obj = mysql_fetch_object($resultset);
$county_name = $obj->county;
} else {
$county_name = "";
}
$cat = str_replace ("~",",",$value['category']);
$selCat = "select * from bullhorn_category_mapping where ip_category in (2)";
//echo $selCat;
$chkResult = mysql_query($selCat);
$category1='';
while($chkValue = mysql_fetch_array($chkResult)){
$category1[] = $chkValue['bh_category'];
}
$skill = str_replace ("~",",",$value['skills']);
$selCat = "select * from bullhorn_skills_mapping where ip_skills in (".$skill.")";
$chkResult = mysql_query($selCat);
$skills='';
while($chkValue = mysql_fetch_array($chkResult)){
$skills[] = $chkValue['bh_skills'];
}

$address_array = array(
'address1' => $value['address1'],
'address2' => $value['address2'],
'city' => $value['town'],
'state' => $county_name,
'zip' => $value['postcode'],
'countryID' => 2359
);

$candidate_array = array(
'distinct' => false,
'firstName' => $value['first_name'],
'lastName' => $value['last_name'],
'username' => $value['user_name'],
'address' => $address_array,
'status' => 'Available',
'userTypeID' => 35,
'categoryID' => '451',
'skillID' => '109824',
'password' => '123456',
'ownerID' => '2',
'occupation' => $value['job_keywords'],
'mobile' => $value['home_telephone'],
'phone' => $value['home_telephone'],
'source' => "Company Website",
'comments'=> $value['comments'],
'customText14'=>$value['visa_type'],
'customText16'=> $value['transport'],
'willRelocate'=> $value['relocate'],
'employeeType' => "1099",
'isDeleted' => '0'
);
$SOAP_dto = new SoapVar($candidate_array, SOAP_ENC_OBJECT, "candidateDto", "http://candidate.entity.bullhorn.com/");
$request_array = array(
'session' => $API_currentSession->session,
'dto' => $SOAP_dto
);
$SOAP_request = new SoapVar($request_array, SOAP_ENC_OBJECT, "save", "http://save.apiservice.bullhorn.com/");
try{

$saveResponse = $BHClient->save($SOAP_request);

} catch (SoapFault $fault) {
var_dump($BHClient->__getLastRequest());
die($fault->faultstring);
}
$API_currentSession = $saveResponse->return->session;
$savedCandidate = $saveResponse->return->dto;
$bh_userId = $savedCandidate->userID;
$query_array = array(
'distinct' => false,
'entityName' => 'Category',
'maxResults' => 10,
'where' => 'enabled = 1',
'parameters' => array() );

$SOAP_query = new SoapVar($query_array, SOAP_ENC_OBJECT, "dtoQuery", "http://query.apiservice.bullhorn.com/");
$request_array = array ( 'session' => $API_currentSession, 'query' => $SOAP_query );

$SOAP_request = new SoapVar($request_array, SOAP_ENC_OBJECT, "query", "http://query.apiservice.bullhorn.com/");
try{
$queryResult = $BHClient->query($SOAP_request);
} catch (SoapFault $fault) {
echo $BHclient->__getLastResult();
die($fault->faultstring);
}

$API_currentSession = $queryResult->return->session;

foreach ($queryResult->return->ids as $value){
$findId = new SoapVar($value, XSD_INTEGER, "int","http://www.w3.org/2001/XMLSchema");
$find_request = array ( 'session' => $API_currentSession,
'entityName' => 'Category',
'id' => $findId );

try{
$findResult = $BHClient->find($find_request); }
catch (SoapFault $fault) { echo $BHclient->__getLastResult(); die($fault->faultstring);
}

$API_currentSession = $findResult->return->session; $foundCategory = $findResult->return->dto;

echo('Found category using find(): '.$foundCategory->categoryID.' - '. $foundCategory->occupation.'<br>');
}
foreach($category1 as $value){
$category_array = array(
'session' => $API_currentSession,
'entityName' => 'Candidate',
'id' => new SoapVar($bh_userId, XSD_INT, "int", "http://www.w3.org/2001/XMLSchema"),
'associationName' => 'categories',
'associateId' => new SoapVar($value, XSD_INT, "int", "http://www.w3.org/2001/XMLSchema") );
print_r($category_array);echo "<br>"; // I can get the values here
$SOAP_request_associate = new SoapVar($category_array, SOAP_ENC_OBJECT, "associate", "http://associate.apiservice.bullhorn.com/");
echo "<br>".$SOAP_request_associate."<br>"; //Nothing is been printed here
try{
$associateResponse = $BHClient->associate($SOAP_request_associate);
}
catch (SoapFault $fault) {
echo $BHclient->__getLastResult();
die($fault->faultstring);
}
}
print_r($associateResponse); //Nothing is been printed here
$API_currentSession = $associateResponse->return->session;

Could you please anyone help over in this issue?

Thanks in Advanced
Srigowsalya K

techteam321
User
Posts: 4
Joined: Sat Jun 23, 2012 7:37 am

Re: Category Association Is not inserted in Bullhorn

Post by techteam321 » Sat Sep 15, 2012 1:55 am

Can anyone please over this issue?

Thanks & Regards,
Srigowsalya K

r.knight
User
Posts: 68
Joined: Wed Dec 31, 1969 8:00 pm

Re: Category Association Is not inserted in Bullhorn

Post by r.knight » Wed Sep 19, 2012 8:03 am

Hi Srigowsalya,

We are reviewing this further and someone should be responding shortly.
Ryan Knight
Principal Enterprise Support Analyst and Team Lead
B U L L H O R N
33-41 Farnsworth Street, 5th Floor, Boston, MA 02210
US Support: 617-478-9126
International Support: +1 617 478 9131
http://www.bullhorn.com

jroorda
User
Posts: 28
Joined: Wed Dec 31, 1969 8:00 pm

Re: Category Association Is not inserted in Bullhorn

Post by jroorda » Wed Sep 19, 2012 8:39 pm

Hello Srigowsalya K,
This is Justin with Bullhorn Support.
There was only one problem with the associate request.
Certain operations in the webservices use different object structure.
In most operations you put the array in a new SOAP var however here you just need the array.
As to which operations need to be setup this way it is a bit more complex as is it is not documented.
We are still trying to determine all the operations that need to be setup differently all I know now is that the getNotes operations and the asscoiate operation are the two that require it now.

If you see the code below it will work.

Code: Select all

<?php
 
$params = array('trace' => 1,
		'soap_version' => SOAP_1_1);
		$BHclient = new SoapClient("https://api.bullhornstaffing.com/webservices-2.0/?wsdl",$params);
		
$username = "*";
$password = "*";
$apiKey = "*";
		
// 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;

$bh_userId = "*";
$value = "*";


$category_array = array( 
'session' => $API_currentSession, 
'entityName' => 'Candidate', 
'id' => new SoapVar($bh_userId, XSD_INT, "int", "http://www.w3.org/2001/XMLSchema"), 
'associationName' => 'categories', 
'associateId' => new SoapVar($value, XSD_INT, "int", "http://www.w3.org/2001/XMLSchema") ); 


print_r($category_array);echo "<br><br />";
$SOAP_request_associate = new SoapVar($category_array, SOAP_ENC_OBJECT, "associate", "http://associate.apiservice.bullhorn.com/");
echo "<br><br />"; echo "<br><br />"; 
print_r($SOAP_request_associate);


try{ 
  $associateResponse = $BHclient->associate($category_array); 
  } catch  (SoapFault $fault) { 
     echo $fault; 
     die($fault->faultstring); 
  }


catch (SoapFault $fault) { 
echo $BHclient->__getLastResult();
die($fault->faultstring); 
} 

print_r($associateResponse); 
$API_currentSession = $associateResponse->return->session;

?>
As you can see there is a small little diffrence.

Code: Select all

Original: $associateResponse = $BHClient->associate($SOAP_request_associate); 

Working:   $associateResponse = $BHclient->associate($category_array); 


So we are using 
$category_array = array( 
'session' => $API_currentSession, 
'entityName' => 'Candidate', 
'id' => new SoapVar($bh_userId, XSD_INT, "int", "http://www.w3.org/2001/XMLSchema"), 
'associationName' => 'categories', 
'associateId' => new SoapVar($value, XSD_INT, "int", "http://www.w3.org/2001/XMLSchema") ); 

Not

$SOAP_request_associate = new SoapVar($category_array, SOAP_ENC_OBJECT, "associate", "http://associate.apiservice.bullhorn.com/");

Post Reply