getSession can give you session id for a particular service context from the server when it started and it’s very useful utility when you want to monitor or track a particular service session.
HEre is the sample of a custom Java service for getting session id