Skip to Content.
Sympa Menu

grouper-users - RE: Help with accessing web services

Subject: Grouper Users - Open Discussion List

List archive

RE: Help with accessing web services


Chronological Thread 
  • From: Chris Hyzer <>
  • To: Paul Gazda <>, "" <>
  • Subject: RE: Help with accessing web services
  • Date: Wed, 4 Feb 2009 16:07:07 -0500
  • Accept-language: en-US
  • Acceptlanguage: en-US

I think the easiest and best way to use grouper web services by code is to use the grouper client API.  Here is an example below that I tested and it works.  All the configuration is in the grouper.client.properties file, and you only need the grouperClient.jar.  Here are the classes you should be using:

 

http://middleware.internet2.edu/dir/groups/grouper/grouper/1.4.1/gc/api/edu/internet2/middleware/grouperClient/api/package-summary.html

 

Here are all the underlying beans:

http://middleware.internet2.edu/dir/groups/grouper/grouper/1.4.1/gc/api/edu/internet2/middleware/grouperClient/ws/beans/package-summary.html

 

 

Full javadoc:

http://middleware.internet2.edu/dir/groups/grouper/grouper/1.4.1/gc/api/index.html

 

Here are example grouper client calls:

http://viewvc.internet2.edu/viewvc.py/grouper-misc/grouperClient/src/java/edu/internet2/middleware/grouperClient/GrouperClient.java?root=I2MI&view=markup

 

That said, I need to put more examples on the grouper client website, if you need help doing something, let me know and I can beef up the docs.

 

Your other code either needs all the dependent jars, or to use the classes in the classpath of the grouperClient.jar.  I took in a minimal number of 3rd party jars into the grouper client jar, and changed their classpath so nothing conflicts.  I wanted this to be very easy for non java people to use, so it is one jar and one config file, and an easy command line.  Java is not as easy to kick off with multiple jars, and less easy to upgrade etc…  there are disadvantages here (like your confusion), but I think the pros outweigh the cons.

 

Regards,

Chris

 

 

 

/*

 * @author mchyzer

 * $Id$

 */

package edu.internet2.middleware.grouperClient.poc;

 

import edu.internet2.middleware.grouperClient.api.GcFindStems;

import edu.internet2.middleware.grouperClient.ws.beans.WsFindStemsResults;

import edu.internet2.middleware.grouperClient.ws.beans.WsResultMeta;

import edu.internet2.middleware.grouperClient.ws.beans.WsStem;

import edu.internet2.middleware.grouperClient.ws.beans.WsStemQueryFilter;

 

 

/**

 *

 */

public class FindStem {

 

  /**

   * @param args

   */

  public static void main(String[] args) {

   

    GcFindStems gcFindStems = new GcFindStems();       

   

    WsStemQueryFilter wsStemQueryFilter = new WsStemQueryFilter();

    wsStemQueryFilter.setStemName("penn");

    wsStemQueryFilter.setStemQueryFilterType("FIND_BY_STEM_NAME_APPROXIMATE");

   

    gcFindStems.assignStemQueryFilter(wsStemQueryFilter);

   

    WsFindStemsResults wsFindStemsResults = gcFindStems.execute();

   

    WsResultMeta resultMetadata = wsFindStemsResults.getResultMetadata();

   

    if (!"T".equals(resultMetadata.getSuccess())) {

      throw new RuntimeException("Error finding stems: " + resultMetadata.getSuccess()

          + ", " + resultMetadata.getResultCode()

          + ", " + resultMetadata.getResultMessage());

    }

   

    WsStem[] wsStems = wsFindStemsResults.getStemResults();

   

    if (wsStems != null) {

      for (WsStem wsStem : wsStems) {

        System.out.println(wsStem.getName());

      }

    }

  }

}

 

 

From: Paul Gazda [mailto:]
Sent: Wednesday, February 04, 2009 1:04 PM
To:
Subject: [grouper-users] Help with accessing web services

 

I am trying to access grouper web services using REST. I am trying to use the sample code for WsSampleFindStemsRestLite (in grouper-ws/src/test/edu/internet2/middleware/grouper/ws/samples/rest/stem) as a model, but I need to incorporate it in a uPortal channel rather than running it from a command line. I keep getting ClassNotFound error for com/thoughtworks/xstream/io/json/JettisonMappedXmlDriver that I can’t get around. I see that the class is in the grouperClient.jar which I have deployed to the proper lib under the uPortal app in Tomcat 5.5.9. But I see that the classpath is different in grouperClient.jar since it prepends edu.internet2.middleware.grouperClientExt to the com.thoughtworks… classpath. Details of the code and error are below.

 

Any help is greatly appreciated.

Paul Gazda

 

 

      HttpClient httpClient = new HttpClient();

 

      DefaultHttpParams.getDefaultParams().setParameter(

          HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(0, false));

 

      //URL e.g. http://localhost:8093/grouper-ws/servicesRest/v1_3_000/...

      //NOTE: aStem:aGroup urlencoded substitutes %3A for a colon

      PostMethod method = new PostMethod(

          "http://testgrouperserver.ucc.nau.edu/grouper-ws/servicesRest/v1_4_000/stems");

 

      httpClient.getParams().setAuthenticationPreemptive(true);

      Credentials defaultcreds = new UsernamePasswordCredentials("xxxxx", "xxxxx");

 

      //no keep alive so response if easier to indent for tests

      method.setRequestHeader("Connection", "close");

 

      //e.g. localhost and 8093

      httpClient.getState()

          .setCredentials(new AuthScope("http:// testgrouperserver.ucc.nau.edu", 80), defaultcreds);

 

      //Make the body of the request, in this case with beans and marshaling, but you can make

      //your request document in whatever language or way you want

      WsRestFindStemsLiteRequest findStemsLite = new WsRestFindStemsLiteRequest();

 

      // set the act as id

      findStemsLite.setActAsSubjectId("GrouperSystem");

 

      findStemsLite.setStemName("NAU");

      findStemsLite.setStemQueryFilterType(WsStemQueryFilterType.FIND_BY_STEM_NAME_APPROXIMATE.name());

 

      //get the xml / json / xhtml / paramString

      WsSampleRestType wsSampleRestType = WsSampleRestType.xhtml;

      String requestDocument = wsSampleRestType.getWsLiteRequestContentType().writeString(findStemsLite);

.

.

.

 

 

When it executes the line “WsSampleRestType wsSampleRestType = WsSampleRestType.xhtml;”

it throws this error:

ERROR [http-8443-Processor25] portal.ChannelRenderer.[] Feb/04 10:38:17 - Unexpected exceptional condition trying to get the result from the workTracker Future rendering channel [edu.nau.its.sia.portal.channels.ldapSvcs.CLdapSvcs@1c304c7].

edu.emory.mathcs.backport.java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: com/thoughtworks/xstream/io/json/JettisonMappedXmlDriver

.

.

.

Caused by: java.lang.NoClassDefFoundError: com/thoughtworks/xstream/io/json/JettisonMappedXmlDriver

          at edu.internet2.middleware.grouper.ws.samples.types.WsSampleRestType.<clinit>(WsSampleRestType.java:17)

          at edu.nau.its.sia.portal.channels.ldapSvcs.LdapAccess.stAliasSearch(LdapAccess.java:5239)

.

.

.

 




Archive powered by MHonArc 2.6.16.

Top of Page