...
Various tools are available for building the stub code such as . wsdl2java in the axis 2 package works well for java development:
...
This will produce the following files:
/src/uk/co/in_time/IntimeServiceV2_0Stub.java
/src/uk/co/in_time/IntimeServiceV2_0CallbackHandler.java
/src/uk/co/in_time/IntimeServiceV2_0IntimeWebServiceException.java
Include and reference these files in your application and you will be able to make calls to the Web Services. Some examples are given below.
...
It is important to enclose your web service calls in try / catch blocks as Exceptions are used as the mechanism for feeding back any issues. For example if you attempt to create a placement without providing an External ID, an exception will be returned from the Web Service call with an appropriate message.
Authenticate
try { //Create an instance of the stub IntimeServiceV2_0Stub stub = new IntimeServiceV2_0Stub("https://demo.in-time.co.uk/services/IntimeServiceV2_0?wsdl"); //Get an authentication token IntimeServiceV2_0Stub.Authenticate auth=new IntimeServiceV2_0Stub.Authenticate(); auth.setAgencyRefCode("<supplied_credentials>"); auth.setUsername("<supplied_credentials>"); auth.setPassword("<supplied_credentials>"); IntimeServiceV2_0Stub.AuthenticateResponse authResp=stub.authenticate(auth); String ticket=authResp.get_return(); System.out.println("Authentication token:" + ticket); //Use this authentication token (ticket) to pass in to any of the other WebService calls } catch (java.lang.Exception e) { System.out.println("Exception occurred: " + e); } |
---|
Create or update a Worker
try { IntimeServiceV2_0Stub.Worker worker = new IntimeServiceV2_0Stub.Worker(); worker.setExternalId("WKR_LTD_001"); worker.setFirstname("Ltd"); worker.setLastname("Worker"); worker.setEmail("x@x.com"); worker.setTitle("Mrs"); worker.setWorkerType("ltd"); worker.setGender("F"); worker.setSelfBilling(false); worker.setAccountsReference("ACC_REF"); worker.setPaymentFrequency("Monthly"); String[] wConsolidation = new String[] { "destination","source","pay-currency","purchase-tax-code","worker","placement" }; worker.setConsolidation(wConsolidation); String[] wCrouping = new String[] { "sheet","sheet-rate" }; worker.setGrouping(wCrouping); Calendar cal = Calendar.getInstance(java.util.TimeZone.getTimeZone("GMT")); cal.set(1980, 0, 1, 0, 0, 0); cal.set(Calendar.MILLISECOND, 0); worker.setDateOfBirth(cal); Calendar cal2 = Calendar.getInstance(java.util.TimeZone.getTimeZone("GMT")); cal2.set(2017, 0, 1, 0, 0, 0); cal2.set(Calendar.MILLISECOND, 0); worker.setDateOfJoining(cal2); IntimeServiceV2_0Stub.Address address = new IntimeServiceV2_0Stub.Address(); address.setLine1("Address1"); address.setLine2("Add2"); address.setTown("Town"); address.setCounty("County"); address.setCountry("UK"); address.setPostcode("AB1 2CD"); address.setCountryCode("GB"); worker.setAddress(address); BankAccount bank = new BankAccount(); bank.setAccountName("Ltd Wkr"); bank.setAccountNumber("12345678"); bank.setBank("bank"); bank.setSortCode("11-22-33"); worker.setBankAccount(bank); Company ltdCompany = new Company(); ltdCompany.setName("Ltd Co Name"); ltdCompany.setCompanyNo("123456789"); ltdCompany.setCompanyVatNo("1234567890"); ltdCompany.setVatCode("T0"); worker.setLimitedCompany(ltdCompany); IntimeServiceV2_0Stub.CreateOrUpdateWorker request = new IntimeServiceV2_0Stub.CreateOrUpdateWorker(); request.setToken(ticket); request.setWorker(worker); IntimeServiceV2_0Stub.CreateOrUpdateWorkerResponse result=stub.createOrUpdateWorker(request); if (result != null) { System.out.println("Created/updated Worker with ID:" + result.get_return()); } } catch (java.lang.Exception e) { System.out.println("Exception occurred: " + e); } |
---|
...