Getting Started
Access to the TalentLink web services is restricted to TalentLink clients. When the service is activated for you, you will be provided with the following :
- Username
- Password
- API Key
- The URL to the web service
You will need all four items for every request that you make.
The roles and rights that have been assigned to the user account determine which data and functions are accessible. The API key restricts access to a single bundle.
In the examples below, the following assumptions have been made :
- UserName : THubUser
- Password : Password1234
- API Key : dabc4dvptajdnrhwnqsf6dnz
- URL : https://api3.lumesse-talenthub.com
Obviously you will need to substitute the example values with your own.
Making a SOAP Request
The URL for a SOAP request is in the format https://api3.lumesse-talenthub.com/[BundleName]/SOAP/[ServiceName]?api_key=[Your api key].
Therefore to make a request to the Position web service within the HRIS bundle, the full URL would be
https://api3.lumesse-talenthub.com/HRIS/SOAP/Position?api_key=dabc4dvptajdnrhwnqsf6dnz
Each SOAP request uses WS-Security, meaning that the SOAP header should look like :
<soap:Header> <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <wsse:UsernameToken wsu:Id="UsernameToken-3" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <wsse:Username>THubUser</wsse:Username> <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Password1234</wsse:Password> </wsse:UsernameToken> </wsse:Security> </soap:Header>
If you are developing using Visual Studio, you may encounter problems if you add a service reference. Visual Studio automatically adds some headers which are incompatible with WS-Security. The code samples below in VB.Net and C# are a solution for this problem.
The method that you wish to call, along with any parameters, goes into the body of the message. To call the getPositionById method which takes a parameter of "id", the SOAP body would look like :
<soap:Body> <ws:getPositionById> <id>1234</id> </ws:getPositionById> </soap:Body>
The full request therefore would be :
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ws.mrted.com/"> <soap:Header> <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> <wsse:UsernameToken wsu:Id="UsernameToken-3" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"> <wsse:Username>THubUser</wsse:Username> <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">Password1234</wsse:Password> </wsse:UsernameToken> </wsse:Security> </soap:Header> <soap:Body> <ws:getPositionById> <id>1234</id> </ws:getPositionById> </soap:Body> </soap:Envelope>
Code Samples
VB.Net
Private Sub PostToTalentHub(m_URL as String)
'Create a request object
Dim request As Net.HttpWebRequest = Net.WebRequest.Create(m_Url)
request.ContentType = "text/xml;charset=""utf-8"""
request.Method = "POST"
request.Headers.Add("SOAPAction", """""")
request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate")
Dim m_PostMsg As String = ""
' This is where you need to build the SOAP message
'm_PostMsg = "<soap:Envelope " etc. ........
Dim objStream As New System.IO.StreamWriter(request.GetRequestStream(), System.Text.Encoding.UTF8)
objStream.Write(m_PostMsg)
objStream.Close()
objStream = Nothing
Dim objHTTPRes As HttpWebResponse
objHTTPRes = request.GetResponse()
Dim SourceStream As IO.Stream = objHTTPRes.GetResponseStream()
'It's up to you how you save the response
'You could save it as an XML document
Dim objXML As New System.Xml.XmlDocument()
objXML.Load(SourceStream)
'Or you could save it to a String
Dim ret As String
Dim sr As System.IO.StreamReader = New IO.StreamReader(SourceStream)
ret = sr.ReadToEnd
End Sub
C#
private void PostToTalentHub(string m_URL)
{
//Create a request object
System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(m_URL);
request.ContentType = "text/xml;charset=\"utf-8\"";
request.Method = "POST";
request.Headers.Add("SOAPAction", "\"\"");
//request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate");
request.AutomaticDecompression = DecompressionMethods.GZip
DecompressionMethods.Deflate;
string m_PostMsg = "";
// This is where you need to build the SOAP message
//m_PostMsg = "<soap:Envelope " etc. ........
System.IO.StreamWriter objStream = new System.IO.StreamWriter(request.GetRequestStream(), System.Text.Encoding.UTF8);
objStream.Write(m_PostMsg);
objStream.Close();
objStream = null;
HttpWebResponse objHTTPRes = default(HttpWebResponse);
objHTTPRes = (HttpWebResponse)request.GetResponse();
System.IO.Stream SourceStream = objHTTPRes.GetResponseStream();
//It's up to you how you save the response
//You could save it as an XML document
System.Xml.XmlDocument objXML = new System.Xml.XmlDocument();
objXML.Load(SourceStream);
//Or you could save it to a String
string ret = null;
System.IO.StreamReader sr = new System.IO.StreamReader(SourceStream);
ret = sr.ReadToEnd();
}
PHP
class TLK_SOAP
{
private $_apiKey = 'API KEY'; // API Key
private $_wsEndPoint = "https://api2.lumesse-talenthub.com/Posting/SOAP/Posting"; // end point for WS
private $_wsUsername = "UserName"; // username for WS
private $_wsPassword = "PWD"; // password for WS
private $_wsSecurityNS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
public $ws = null; // holder of web service for future calls
function __construct(array $config)
{
$soap_Username = new SoapVar($this->_wsUsername, XSD_STRING, NULL, $this->_wsSecurityNS, NULL, $this->_wsSecurityNS);
$soap_Password = new SoapVar($this->_wsPassword, XSD_STRING, NULL, $this->_wsSecurityNS, NULL, $this->_wsSecurityNS);
$soap_Auth = new WSSEAuth($soap_Username, $soap_Password);
$soapVar_Auth = new SoapVar($soap_Auth, SOAP_ENC_OBJECT, NULL, $this->_wsSecurityNS, 'UsernameToken', $this->_wsSecurityNS);
$soap_Auth_Token = new WSSEToken($soapVar_Auth);
$soapVar_Auth_Token = new SoapVar($soap_Auth_Token, SOAP_ENC_OBJECT, NULL, $this->_wsSecurityNS, 'UsernameToken', $this->_wsSecurityNS);
$soapVar_Security = new SoapVar($soapVar_Auth_Token, SOAP_ENC_OBJECT, NULL, $this->_wsSecurityNS, 'Security', $this->_wsSecurityNS);
$soapVar_Header = new SoapHeader($this->_wsSecurityNS, 'Security', $soapVar_Security, true, "TlkPrincipal");
try
{
$this->ws = @new SoapClient($this->_wsEndPoint . '?wsdl');
$this->ws->__setSoapHeaders(array($soapVar_Header));
$this->ws->__setLocation($this->_wsEndPoint . '?api_key=' . $this->_apiKey);
}
catch (Exception $e)
{
echo $e->getMessage();
}
}
}
// additional classes to facilitate WSSE addition to standard SOAP for PHP
class WSSEAuth
{
private $Username;
private $Password;
function __construct($username, $password)
{
$this->Username = $username;
$this->Password = $password;
}
}
class WSSEToken
{
private $UsernameToken;
function __construct ($token)
{
$this->UsernameToken = $token;
}
}
Useful Tools for Testing
SOAP Ui - A free tool for testing calls to SOAP web services. (http://sourceforge.net/projects/soapui/files/)