[MOBY-dev] Problems calling a Moby service with secondary parameters

Paul Gordon gordonp at ucalgary.ca
Wed Sep 10 19:35:11 UTC 2008


Hi Michael,

Sorry for not getting back to you earlier.  The problem is in the way to 
create the secondary data instances.  If you do a toString() on them, 
you;ll see that they have a blank name based on the constructor you 
used.  The easiest way to use the default secondaries is with the 
one-arg constructor, e.g.:

int i = 0;
for (MobySecondaryData param: service.getSecondaryInputs()) {
        secParams[i++] = new MobyDataSecondaryInstance(param);  
//auto-populates the instance with the template's default value
}

I'll add a check to MobyRequest that'll complain if you give blank or 
duplicately named secondaries, which should make this mistake more 
obvious to others in the future.

Regards,

Paul

P.S. I've also updated MobyDataComposite to handle put() for cases such 
as your where the data type is not in the registry yet, facilitating 
testing.  Better yet though is to use the test registry in such cases.

Michael Gerlich wrote:
> Hi all,
>
> I'm working on a simple java app (client) that calls some Biomoby services I
> wrote (for JUnit testing). One of these, "get_DBLinks_From_Peaklist"
> registered under authority "ipb-halle.de" takes additional 2 secondary
> parameters that modify its query behavior and the resulting number of
> outputs.
>
> Now when I try to add both secondary parameters to the input, the service
> call fails with the following message:
>
> Exception in thread "main" org.biomoby.shared.MobyException: Service
> get_DBLinks_From_Peaklist was provided 1 secondary input parameter(s), but
> takes 2 (query 1).  Extra secondary parameters must have been specified
> 	at
> org.biomoby.client.MobyRequest.convertMOBYDataToMOBYRequest(MobyRequest.java
> :928)
> 	at
> org.biomoby.client.MobyRequest.invokeService(MobyRequest.java:302)
> 	at
> org.biomoby.client.MobyRequest.invokeService(MobyRequest.java:282)
> 	at
> org.biomoby.client.MobyRequest.invokeService(MobyRequest.java:275)
> 	at test.Moby_JUnit_Tests.main(Moby_JUnit_Tests.java:86)
>
>
> My code is like that:
>
> Central worker = new CentralImpl();
> templateService = new MobyService("get_DBLinks_From_Peaklist", authority);
> // authority = "ipb-halle.de"
> validServices = worker.findService(templateService);
> 		
> comp = new MobyDataComposite(new MobyDataType("MSPeakRel"));
> comp.put("relInt", new MobyDataInt(999));
> comp.put("mz", new MobyDataFloat(273.069));
>
> MobyDataSecondaryInstance[] secParams = new
> MobyDataSecondaryInstance[validServices[0].getSecondaryInputs().length];
> for (int i = 0; i < validServices[0].getSecondaryInputs().length; i++) {
> 	secParams[i] = new MobyDataSecondaryInstance(new
> MobySecondaryData(validServices[0].getSecondaryInputs()[i].getDataType()),
> validServices[0].getSecondaryInputs()[i].getDefaultValue());		}
> 		
> 		mr.setService(validServices[0]);
> 		mr.setInput(comp);
> 		mr.setSecondaryInput(secParams);
> 		System.out.println(mr.invokeService().toString());
>
>
>
> The setSecondaryInput() function takes an array that consists of all
> parameters and applies them to all inputs. Now there are 2 parameters and an
> array of length 2 - with the default values for both parameters (I defined
> default values for both parameters).
>
> Some hints what I'm doing wrong?
>
>
> Another question - my input is of type MSPeakRel and is defined as
> collection. How do I manage to add multiple inputs - in this case, they
> would represent a complete peaklist of (m/z value, relative intensity) for
> querying a database?
>
>
>
> Best wishes,
>
> Michael
>
> _______________________________________________
> MOBY-dev mailing list
> MOBY-dev at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/moby-dev
>
> !DSPAM:60005,48be578210950321565264!
>
>
>
>   



More information about the MOBY-dev mailing list