Use the RestSession.startSession() method to start a REST session without authenticating the client. You can log into the REST server after you start the session if that is required.

Note: Starting a session without logging in will not give your REST client access to secured Oracle Commerce Platform resources.

The following sample program starts a REST session using the startSession() method.

import atg.rest.client.RestClientException;
import atg.rest.client.RestSession;
public class RestClientStartSession {
  // Use your own hostname and port.
  private String mHost = "myserver";
  private int mPort = 9876;
  private RestSession mSession = null;
  public RestClientStartSession() {}

  protected void execute() throws RestClientException {

    // Create a RestSession object. Use the constructor that
    // takes only the REST server host and port.
    mSession = RestSession.createSession(mHost, mPort);

    // Invoke the startSession() method.
    mSession.startSession();

    // Verify that the session is started.
    String sessionid = mSession.getSessionId();
    System.out.println("The session ID is: " + sessionid);

    // perform unsecured operations or login here
    // forexample:
    // mSession.login("myusername","mypassword")
  }

  public static void main(String[] args) {
    RestClientStartSession sample = new RestClientStartSession();
    try {
      sample.execute();
    }
    catch (Throwable t) {
      t.printStackTrace(System.out);
    }
  }
}

Copyright © 1997, 2015 Oracle and/or its affiliates. All rights reserved. Legal Notices