[MOBY-l] Moby Client Example

Carol Lushbough Carol.Lushbough at usd.edu
Fri May 5 13:21:58 UTC 2006


All,

I was wondering if someone could send me an example demonstrating how a 
java client app retrieves output after invoking a BioMoby service.  I'm 
trying to test a service that returns a collection of 
BasicGFFSequenceFeature. The following code segments are my attempts at 
retrieving the collection:

                // First try
           mr.invokeService();
           MobyContentInstance output = mr.getOutput();
           BasicGFFSequenceFeature[] values =  
(BasicGFFSequenceFeature[]) output.get("locations");

          // second try
            MobyContentInstance responses = mr.invokeService();

        Iterator i = responses.keySet().iterator();
        while(i.hasNext()){
                HashMap responseObjects = (HashMap) responses.get(i.next());
                 Iterator it = responseObjects.keySet().iterator();
                 while(it.hasNext()){
                    Object responseObject = it.next();
                    // The response objects may either be simple data, 
or data sets
            if(responseObject instanceof MobyDataObject){
            System.out.println("Plain simple instance is 
"+((MobyDataInstance)responseObject).toXML());
            }
            else if(responseObject instanceof MobyDataObjectSet){
            System.out.println("Found a collection:");
            MobyDataObject[] simples = ((MobyDataObjectSet) 
responseObject).getElementInstances();
            for(int j = 0; j < simples.length; j++){
                System.out.println("  Member instance is 
\n"+simples[j].toXML());
            }
            }
            else{
            System.out.println("Found funky data!" + 
responseObject.toString());
            }
        }
        }

Thank you for you help!

Carol

-- 
Carol Lushbough
Assistant Professor of Computer Science
University of South Dakota
Vermillion, SD 57069
(605) 677-6138




More information about the moby-l mailing list