Skip to Content.
Sympa Menu

grouper-dev - RE: RE: [grouper-dev] Web services prototype done

Subject: Grouper Developers Forum

List archive

RE: RE: [grouper-dev] Web services prototype done


Chronological Thread 
  • From: Chris Hyzer <>
  • To: "Stephen M. Barrett" <>
  • Cc: "" <>
  • Subject: RE: RE: [grouper-dev] Web services prototype done
  • Date: Mon, 10 Dec 2007 11:48:20 -0500
  • Accept-language: en-US
  • Acceptlanguage: en-US

Well, an easier example than waiting for a different language, is I wrote a Java REST web service client that parses and validates all the XML (posted on site, and below in email).  This doesn’t use the actual Java type that the service method returns, it just parses XML.  So if you translated this into any programming language, then you will be able to use the web services.  It took me about 30 minutes to code…  

 

Kind regards,

Chris

 

package edu.internet2.middleware.grouper.webservicesClient;

 

import java.io.Reader;

import java.io.StringReader;

import java.util.List;

 

import org.apache.commons.httpclient.HttpClient;

import org.apache.commons.httpclient.methods.GetMethod;

import org.jdom.Document;

import org.jdom.Element;

import org.jdom.input.SAXBuilder;

 

public class RunGrouperServiceNonAxis {

 

                /**

                 * @param args

                 */

                @SuppressWarnings("unchecked")

                public static void main(String[] args) throws Exception {

                                HttpClient httpClient = new HttpClient();

                                GetMethod getMethod = new GetMethod(

                                                                "http://localhost:8090/grouper/services/GrouperService/findAll?query=100abcd");

                                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();

                                Reader xmlReader = new StringReader(response);

                                try {

                                                // process xml

                                                Document document = new SAXBuilder().build(xmlReader);

                                                Element findAllResponse = document.getRootElement();

                                                assertTrue("findAllResponse".equals(findAllResponse.getName()),

                                                                                "root not findAllResponse: " + findAllResponse.getName());

 

                                                // process each child

                                                List<Element> returns = findAllResponse.getChildren();

                                                for (Element theReturn : returns) {

 

                                                                // make sure they have the right element name and type

                                                                assertTrue("return".equals(theReturn.getName()),

                                                                                                "element not 'return': " + theReturn.getName());

                                                                assertTrue(

                                                                                                "edu.internet2.middleware.grouper.webservices.WsSubject"

                                                                                                                                .equals(theReturn.getAttributeValue("type")),

                                                                                                "type is: " + theReturn.getAttributeValue("type"));

 

                                                                String description = theReturn.getChild("description",

                                                                                                findAllResponse.getNamespace()).getValue();

                                                                String id = theReturn.getChild("id",

                                                                                                findAllResponse.getNamespace()).getValue();

                                                                String name = theReturn.getChild("name",

                                                                                                findAllResponse.getNamespace()).getValue();

 

                                                                System.out.println(id + " - " + name + " - " + description);

 

                                                }

                                } finally {

                                                try {

                                                                xmlReader.close();

                                                } catch (Exception e) {

                                                }

                                }

 

                }

 

                /**

                 * assert like java 1.4 assert

                 *

                 * @param isTrue

                 * @param reason

                 */

                private static void assertTrue(boolean isTrue, String reason) {

                                if (!isTrue) {

                                                throw new RuntimeException(reason);

                                }

                }

 

}

 

From: Chris Hyzer [mailto:]
Sent: Monday, December 10, 2007 10:50 AM
To: Stephen M. Barrett
Cc:
Subject: RE: [grouper-dev] Web services prototype done

 

Stephen,

 

Thanks for raising this issue.

 

For clients which are not using Java, then I think the Java service class is not what should be looked at, but rather the WSDL and example XML.  This is the integration point, not Java.  Granted the XML that Axis generates based on the Java types might not be what we would decide on as a group would be most efficient, but it is not terrible.  Hopefully there are toolkits like Axis for whatever language you are using which would generate classes in that language so you wouldn’t have to worry about it.  And I hope that people in whatever language can post examples about it.  If the only code generation we gain from SOAP is Java and .NET, then I think there is still a huge gain.  The Grouper team will have a lot web service operations to maintain (and I think some non-simple data-structures), and if we can do it automatically and not roll XML by hand it would be a lot more reliable and less expensive to maintain/test for the grouper project.  So the other technologies which do not yet have WSDL->code generation can just hand-roll the XML that Axis auto generated.

 

That being said, if we *do specify* the XML and have all services as String input -> String output or something simple, Xstream is a free jar which does this well, and grouper could use that.

 

Is that an acceptable answer?  J

 

Maybe we need an example client to connect to my proof of concept service to show how this would work (to me or others).  If someone is a whiz web service client developer in non-java, and has some extra cycles, let me know and we can get something working against my proof of concept, and we can post the code.

 

This is definitely a topic to discuss at the next dev-meeting, and I added the issue to the web services grouper page.

 

Kind regards!

Chris

 

 

From: Stephen M. Barrett [mailto:]
Sent: Monday, December 10, 2007 10:10 AM
To: Chris Hyzer
Cc:
Subject: Re: [grouper-dev] Web services prototype done

 


Chris, I am concerned that the return type is a defined java class.  This would indicate that clients must possess the appropriate java client package to take advantage of the service.  This has several disadvantages.  The first being that other languages would not be able to easily consume the service.  The second is that all client SW would have a version dependency on the Grouper SW which is difficult to support.  I wonder if we can find a way to support an array of objects and elements without requiring the return type to be "edu.internet2.middleware.grouper.webservices.WsSubject".

It may be better to simply deal with raw XML for formated I/O and simple types for all other parameters.

But this is great progress.  Nice going.


Chris Hyzer wrote:

I did a simple web services prototype.  The details are here:
 
https://wiki.internet2.edu/confluence/display/GrouperWG/WS+-+Proof+of+Concept+2007-10-2007
 
The original Grouper web services page is here, with updated issues and items at bottom.
https://wiki.internet2.edu/confluence/display/GrouperWG/Grouper+-+Web+Services
 
Please give me any feedback.  I will continue to work on it.  Hopefully we can discuss it at the next dev call.
 
  
As you mention doing a simple search for subjects it would be worth taking
into account the 1.0 Subject API. It loses 'type' as a first class
    
 
Gary, thanks for the head's up.  At this point I will just call the same methods that the UI calls, so if we fix the UI with the proper Subject API, the web services will probably be fixed also.  But lets discuss this task a the next call to make sure the order of operations is optimal.
 
Kind regards,
Chris
 
--On 07 December 2007 03:11 -0500 Chris Hyzer  wrote:
 
  
 
Hey grouper-devs,
 
 
 
I added information to the wiki based on emails and discussions we
have had recently.  Note that not everything is there, only things
that seemed like they had some consensus.  Let me know of additions
you would like to see, or feel free to add them yourself.
 
 
 
https://wiki.internet2.edu/confluence/display/GrouperWG/Grouper+-+Web+
Ser
vices
 
 
 
I am a grouper team member working on web services, fyi.  So expect
more communications about web services in the next few weeks/months.
 
 
 
I will be building a prototype in Axis to do a simple Soap web service
(e.g. simple search for a subject).  Then I would like to make a Rest
version of the same logic.  Let me know if you have any advice or
concerns.
 
 
 
Kind regards,
 
Chris
    
 
  

 




Archive powered by MHonArc 2.6.16.

Top of Page