Web Service API authentication issue

Wednesday, January 4, 2012
Avatar
I am using the Web Service API to update some test run data.

I call connection_Authenticate which returns "true"

I then call connection_ConnectToProject with a Project ID I know exists, and it throws an exception "The session was not authenticated, please call the Connection_Authenticate() method first"

I have also tried using
2 Replies
Thursday, January 5, 2012
Avatar
re: cstott Wednesday, January 4, 2012
Sorry about previous post ending abruptly, messed up the cut & paste.

I tried using:

          ((BasicHttpBinding_IImportExportStub)service).setUsername("Integrator");
          ((BasicHttpBinding_IImportExportStub)service).setPassword("Password0");

but still get the same error.

Full code snippet follows, user and password are valid, exception occurs on ConnectToProject, as stated, same result with .setUsername/.setPassword lines commented:

<code>
  public static void main(String[] argv) {
      RemoteTestCase[] tcs;
      Boolean rcFlag;
      try {
          ImportExportLocator locator = new ImportExportLocator();
          IImportExport service = locator.getBasicHttpBinding_IImportExport();
          // If authorization is required
          ((BasicHttpBinding_IImportExportStub)service).setUsername("Integrator");
          ((BasicHttpBinding_IImportExportStub)service).setPassword("Password0");
          // invoke business method
          rcFlag = service.connection_Authenticate("Integrator", "Password0");
          System.out.println("Authenticate returns " + rcFlag.toString());
          rcFlag = service.connection_ConnectToProject(10);
          System.out.println("ConnectToProject returns " + rcFlag.toString());

          RemoteFilter[] remoteFilters = new RemoteFilter[1];
          remoteFilters[0].setPropertyName("NAME");
          remoteFilters[0].setStringValue("ConnectToWebService");

          tcs = service.testCase_Retrieve(remoteFilters, 0, 0);
          System.out.printf("Found %d test cases", tcs.length);

      } catch (javax.xml.rpc.ServiceException ex) {
          ex.printStackTrace();
      } catch (java.rmi.RemoteException ex) {
          ex.printStackTrace();
      }
  }
</code>

Thursday, January 5, 2012
Avatar
re: cstott Wednesday, January 4, 2012
You need to turn on cookie handling on the web service proxy and that will fix the issue. The session cookie from the first Authenticate call is not being passed to the subsequent calls.

Spira Helps You Deliver Quality Software, Faster and With Lower Risk

And if you have any questions, please email or call us at +1 (202) 558-6885

 

Statistics
  • Started: Wednesday, January 4, 2012
  • Last Reply: Thursday, January 5, 2012
  • Replies: 2
  • Views: 3296