Skip to Content.
Sympa Menu

grouper-dev - RE: [grouper-dev] Where the web services will live

Subject: Grouper Developers Forum

List archive

RE: [grouper-dev] Where the web services will live


Chronological Thread 
  • From: Chris Hyzer <>
  • To: Tom Barton <>
  • Cc: Grouper Dev <>
  • Subject: RE: [grouper-dev] Where the web services will live
  • Date: Tue, 15 Jan 2008 04:07:46 -0500
  • Accept-language: en-US
  • Acceptlanguage: en-US

Hey,

Most people wanted Option #1 (actually everyone who responded wanted it), so
grouper-ws is a separate project with separate configs/libs. That was easy.

I created grouper-ws in CVS, and three projects inside:

grouper-ws/grouper-ws: the web service itself
grouper-ws/grouper-ws-java-generated-client: axis generated client
grouper-ws/grouper-ws-java-manual-client: manual REST example of the simple
api

I will need to add a README.txt so you know how to get started, but
everything is working fine with the new projects and new build scripts etc.

I have HTTP basic authentication working with Axis and REST, and the actAs
working also:

https://wiki.internet2.edu/confluence/display/GrouperWG/Authentication

I am pretty much done with addMember. Everything is done except
documentation, unit tests, and transaction implementation.

Here are example clients (similar to before, but took into account feedback
from people):

Axis generated:

GrouperServiceStub stub = new GrouperServiceStub(
"http://localhost:8090/grouper-ws/services/GrouperService";);
Options options = stub._getServiceClient().getOptions();
HttpTransportProperties.Authenticator auth = new
HttpTransportProperties.Authenticator();
auth.setUsername("user");
auth.setPassword("pass");

options.setProperty(HTTPConstants.AUTHENTICATE, auth);
options.setProperty(HTTPConstants.SO_TIMEOUT, new Integer(3600000));
options.setProperty(HTTPConstants.CONNECTION_TIMEOUT, new
Integer(3600000));

AddMember addMember = AddMember.class.newInstance();

//set the act as id
WsSubjectLookup actAsSubject = WsSubjectLookup.class.newInstance();
actAsSubject.setSubjectId("GrouperSystem");
addMember.setActAsSubjectLookup(actAsSubject);

//just add, dont replace
addMember.setReplaceAllExisting("F");

WsGroupLookup wsGroupLookup = WsGroupLookup.class.newInstance();
wsGroupLookup.setGroupName("aStem:aGroup");
addMember.setWsGroupLookup(wsGroupLookup);

//add two subjects to the group
WsSubjectLookup[] subjectLookups = (WsSubjectLookup[])
Array.newInstance(WsSubjectLookup.class,
2);
subjectLookups[0] = WsSubjectLookup.class.newInstance();
subjectLookups[0].setSubjectId("10021368");

subjectLookups[1] = WsSubjectLookup.class.newInstance();
subjectLookups[1].setSubjectId("10039438");

addMember.setSubjectLookups(subjectLookups);

WsAddMemberResults wsAddMemberResults =
stub.addMember(addMember).get_return();


System.out.println(ToStringBuilder.reflectionToString(wsAddMemberResults));

HttpClient REST:

HttpClient httpClient = new HttpClient();
GetMethod getMethod = new GetMethod(

"http://localhost:8091/grouper-ws/services/GrouperService/addMemberSimple?groupName=aStem:aGroup&subjectId=10021368&actAsSubjectId=GrouperSystem";);

httpClient.getParams().setAuthenticationPreemptive(true);
Credentials defaultcreds = new UsernamePasswordCredentials("user",
"pass");
httpClient.getState().setCredentials(new AuthScope("localhost", 80),
defaultcreds);

httpClient.executeMethod(getMethod);

int statusCode = getMethod.getStatusCode();

// see if request worked or not
if (statusCode != 200) {
throw new RuntimeException("Bad response from web service: " +
statusCode);
}

String response = getMethod.getResponseBodyAsString();

//lets load this into jdom, since it is xml
Reader xmlReader = new StringReader(response);
try {
// process xml
Document document = new SAXBuilder().build(xmlReader);
Element addMemberSimpleResponse =
document.getRootElement();

//parse: <ns:addMemberSimpleResponse
xmlns:ns="http://webservices.grouper.middleware.internet2.edu/xsd";>

assertTrue("addMemberSimpleResponse".equals(addMemberSimpleResponse.getName()),
"root not addMemberSimpleResponse: "
+ addMemberSimpleResponse.getName());

Namespace namespace =
addMemberSimpleResponse.getNamespace();

//parse: <ns:return
type="edu.internet2.middleware.grouper.webservices.WsAddMemberResult">
Element returnElement =
addMemberSimpleResponse.getChild("return", namespace);
String theType =
returnElement.getAttributeValue("type");

assertTrue("edu.internet2.middleware.grouper.webservices.WsAddMemberResult"
.equals(theType),
"type not
edu.internet2.middleware.grouper.webservices.WsAddMemberResult: " + theType);

//<ns:errorMessage
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:nil="true" />
String errorMessage =
returnElement.getChildText("errorMessage", namespace);

//<ns:resultCode
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:nil="true" />
String resultCode =
returnElement.getChildText("resultCode", namespace);

//<ns:subjectId>GrouperSystem</ns:subjectId>
String subjectId =
returnElement.getChildText("subjectId", namespace);

//<ns:subjectIdentifier
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:nil="true" />
String subjectIdentifier =
returnElement.getChildText("subjectIdentifier", namespace);

//<ns:success>T</ns:success>
String success =
returnElement.getChildText("success", namespace);

System.out.println("Success: " + success + ",
resultCode: " + resultCode + ", subjectId: " + subjectId
+ ", subjectIdentifier: " +
subjectIdentifier + ", errorMessage: " + errorMessage);

} finally {
try {
xmlReader.close();
} catch (Exception e) {
}
}


Kind regards,
Chris

> -----Original Message-----
> From: Tom Barton
> [mailto:]
> Sent: Thursday, January 10, 2008 11:04 AM
> To: Chris Hyzer
> Cc: Grouper Dev
> Subject: Re: [grouper-dev] Where the web services will live
>
> Thanks Chris. One clarification: with the designations grouper-ui for
> the UI project and grouper-ws for the WS project, are options 1-3 below
> meant to be
>
> 1. grouper-ws is its own cvs project with its own libs & config.
>
> 2. grouper-ws is its own cvs project sharing libs and config with
> grouper-ui, ie, union of UI and WS needs.
>
> 3. grouper-ws is a part of the grouper-ui project, with configuration &
> build options to stand up the UI alone, the WS alone, or both.
>
> I'm currently leaning towards #1, but keeping in mind that we really
> need to adopt Spring or the like across the i2mi wares (grouper-*,
> signet-*, subject api, ldappc) which promises to remove the additional
> complexity of managing separate grouper-ws config and libs.
>
> Tom
>




Archive powered by MHonArc 2.6.16.

Top of Page