Onvif Java Library - Get snapshot URI

Now you are connected to your device and able to work with it. There are different categories to work on, seperated on different handlers that you can call on your OnvifDevice object. Currently there are four types but in a later version there might be more.

OnvifDevice nvt = new OnvifDevice("", "admin", "password");
nvt.getDevices(); // Basic methods for configuration and information
nvt.getMedia(); // Methods to get media information like stream or screenshot URIs or to change your video encoder configuration
nvt.getImaging(); // A few functions to change your image settings, really just for your image settings!
nvt.getPtz(); // Functionality to move your camera (if supported!)

Our first goal is to get a snapshot URI of our camera (not every must support this, but most NVT should do). So we will work on with our media methods and there are some methods to achieve our goal. Don't get irritated by the fact that there are methods to get snapshot- and screenshot-URIs, they return the same and have just different names.

getDefaultSnapshotUri() : String
getSnapshotUri(profileToken : String) : String

So, we have a method without and one with parameter. The first one is a deprecated method and will can be removed in further updates, we should use the other one.
But getSnapshotUri() needs a String profileToken. You now need to know, that every ONVIF device works with profiles for different settings. Some devices just use one profile (so there is not much to chose) but others have multiple profiles. A good tool to look at the different profiles is the Onvif Device Manager. So, before we can get our snapshot URI we need to get a profile token first!

You can get your device profiles with the initial devices.

OnvifDevice nvt = new OnvifDevice("", "admin", "password");
List<Profile> profiles = nvt.getDevices().getProfiles();

You can now look at the different profiles and look at the resolution data of these, we simplify that process (feel free to do it in another way!) and just use the first profile to get our snapshot URI.

import java.net.ConnectException;
import java.util.List;

import javax.xml.soap.SOAPException;

import org.onvif.ver10.schema.Profile;

import de.onvif.soap.OnvifDevice;

public class OnvifTest {
   public static void main(String[] args) {
      try {
         OnvifDevice nvt = new OnvifDevice("", "admin", "password");
         List<Profile> profiles = nvt.getDevices().getProfiles();
         String profileToken = profiles.get(0).getToken();
         System.out.println("Snapshot URI: "+nvt.getMedia().getSnapshotUri(profileToken));
      catch (ConnectException e) {
         System.err.println("Could not connect to NVT.");
      catch (SOAPException e) {

In my case, I get this output:

Snapshot URI: