I recently had an interesting question from a customer who was looking to post to some job boards who accepted XML input, but who did not support the standard HR-XML format. This is an interesting challenge for many companies. Indeed, even job boards who accept HR-XML formatted data may be a challenge since they may want specific attribution, e.g. locations or job categories which the define. Fortunately there is a simple solution to this, which I am reproducing here:
There are two problems to be overcome here. The first is to get the outgoing data in the correct format. This is something that is possible to do fairly well with our stylesheets, which allow you to transform the data in to any format, as long as you don't want to significantly alter the actual data values. If you do need to significantly alter the data, this is not trivial to do in a stylesheet.
The second problem is that we only accept an HR-XML response, and are not flexible about the format of that. Any other response will result in an error code being displayed (IRC_412087_TP_BAD_VENDOR_XML), and the posting URL will not be recorded.
A simple way to solve both of these issues is to create a basic interface between iRecruitment and the job board, which translates the data in and out. This sounds complex, but with basic scripting languages such as perl, or jsp, this is very easy to do. We will demonstrate with a worked example.
First of all, we want to create a stylesheet to translate our data in to a format that is as near as possible to the desired format. In this case, we want an output like this;
<xml version = "1.0"?>
<PostJobDataSet>
<Users>
<UserName>bob</UserName>
<Password>secret</Password>
<Jobs>
<title>Software Engineer</title>
<short_desc>This is a software engineer job</short_desc>
<long_desc>This is a software engineer job.
What a great job!</long_desc>
<location>READING, UK</location>
</Jobs>
</Users>
</PostJobDataSet>
To do this, we create a simple stylesheet in the $OA_HTML, called JobPost1.xsl
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" indent="yes" />
<xsl:template match="jobpositionposting">
<xsl:for-each select="row"><?xml version = "1.0"?>
<PostJobDataSet>
<Users>
<UserName><xsl:value-of select="posting_username "/></UserName>
<Password><xsl:value-of select="posting_password "/></Password>
<Jobs>
<title><xsl:value-of select="job_title"/></title>
<short_desc><xsl:value-of select="brief_description"/></short_desc>
<long_desc><xsl:value-of select="detailed_description"/></long_desc>
<location><xsl:value-of select="town_or_city"/></location>
</Jobs>
</Users>
</PostJobDataSet>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
This stylesheet will create the data in the format that we want, other than the location, which will be in lower case.
We then create a simple perl script as follows, called postData1.pl. This can be placed in any cgi-bin directory inside your firewall.
#!/usr/local/bin/perl -wuse CGI::Carp qw( fatalsToBrowser );
use CGI;
use HTTP::Request::Common qw(POST);
use LWP::UserAgent;# look at the request method
my $method = $ENV{'REQUEST_METHOD'};
my $text;
# get the submitted string
if ($method eq "GET") {
$text = $ENV{'QUERY_STRING'};
}else {
# default to POST
read(STDIN, $text, $ENV{'CONTENT_LENGTH'});
}#find the xml tag in the posted text
$locstart=index($text,"<location>");
if($locstart>0) {
$locend=index($text,"</location>");#get the location value
$locationtext=substr($text,$locstart+10,$locend-($locstart+10));#manipulatethe location value and create the new xml
$newlocation=uc($locationtext);
$newxml=substr($text,0,$locstart+10);
$newxml=$newxml.$newlocation.substr($text,$locend);
} else {
$newxml=$text;
}# create the post to the new URL
$ua = LWP::UserAgent->new();
# enter your proxy server here if applicable
$ua->proxy('http','http://www-proxy.us.oracle.com:80');
my $req = POST 'http://www.yahoo.com',
[ xml => $text];
#read the response
$response=$ua->request($req);
if($response->is_success()){
# if successful, process the response to get the data out
$content = $ua->request($req)->as_string;
# you should add a check here for success
$statuscode="200";
$statusdesc="Success (ok)";
# you should add the correct processing here to pull the URL
# from the response if it was a success
$respURL="http://www.test.com/post?id=1";} else {
# the post failed, so get the http error code
$statuscode=$response->code();
$statusdesc=$response->message();
$respURL=$response->status_line;
}#create the translated response
$myresponse="<?xml version = \"1.0"?>
<Envelope version = "01.00">
<Sender>
<Id>postTest</Id>
</Sender>
<Recipient>
<Id>postTest</Id>
</Recipient>
<TransactInfo type= "response">
<TansactId>1</TansactId>
<TimeStamp>2000-01-01T00:00:00</TimeStamp>
<Status>
<Code>$statuscode</Code>
<ShortDescription>$statusdesc</ShortDescription>
</Status>
</TransactInfo>
<Packet>
<PacketInfo packetType = "response">
<PacketId>1</PacketId>
<Action>OracleHRMSJobPosting</Action>
<Manifest>URL</Manifest>
</PacketInfo>
<Payload>$respURL</Payload>
</Packet>
</Envelope>";#send the response back
print "Content-type: text/xml\n\n";
print $myresponse;
This script will take the xml that it receives, change the location to be upper case, and then post it to another URL. When it gets the response, it will look at the response and create an HR-XML style message based on that, and then send that message back to the application server.
To put this all of this in to action, you then just need to create a new recruiting site, where the posting URL is the URL of your perl script, and the stylesheet is JobPost1.xsl. The script is then called by iRecruitment when you post an advert, and will act as an intermediary between iRecruitment and whatever format the job board chooses to use.
You can create as many copies of the script as you have job boards, editing the URL and the formatting based on the requirements of each job board. You will note that none of this required any customization of any Oracle code, so is not going to be effected by any patches or upgrades either. That's the beauty of web services!
Comments (3)
A very informative post Martin. I have a related question. I am new to iRecruitment and am struggling to find the XML data created when a job is posted to an external board. Can you help?
Posted by David Barnes | July 24, 2006 10:12 AM
Posted on July 24, 2006 10:12
The XML data is not actually stored in the system - it is generated on the fly using the package irc_jpp_generator. You could run that package to generate your xml in test, however it is not a supported api for permanent use.
Posted by Martin Millmore | July 24, 2006 10:26 AM
Posted on July 24, 2006 10:26
Many thanks for the pointer.
Regards,
David
Posted by David Barnes | July 27, 2006 9:29 AM
Posted on July 27, 2006 09:29