[MOBY-dev] JAX-WS BioMoby API (2nd round).

Dmitry Repchevsky dmitry.repchevski at bsc.es
Wed Jan 16 11:44:53 UTC 2008


Hello Paul,

Thank you for giving your opinion. I appreciate it and have some 
comments/questions

> I actually made a version of MobyRequest that uses javax.xml.ws* 
So how you handle famous "soap-encoding"?
I mean that Axis 1.x is the only API which handle Moby on a server side 
so far.
As I commented in various occasions Moby clients ignore WSDL file and 
name parameters differently.
Another JAX-RPC API (SUN, JBoss) failed with Moby requests.

> Version 5 and version 6 don't like to live together in jMOBY
Actually JAX-WS can be installed apart to use with JDK5.
JEE5 specification uses JDK5, but makes JAX-WS obligatory. If fact this 
is what I'm doing using JBoss 4.2.2 (JDK5 + JBoss-WS/JAXB).

> I'd also suggest that even with your own 
> marshalling/unmarshalling, you could easily reuse the existing API 
> classes for data instances that users are familiar with...
I think I didn't explain in well. There is no "my own 
marshalling/unmarshalling". The generated classes are the JAXB annotated 
Java classes.
There is no "marshalling/unmarshalling" in these classes. On the over 
side MoSeS generated datatype classes explicitly contain marshalling 
method ("public org.jdom.Element toXML()")
which makes them jdom dependant. Moreover, standard Java webservices 
architecture JAX-WS (used in JDK6/JEE) uses JAXB to parse webservices 
parameters, so once you wish to go further and
use STANDARD webservices in Java (not soap-encoding) you are doomed to 
use JAXB o stick with parsing it yourself forever.

By now Moby is using the latter case (I don't try to explain you the 
obvious, but to clarify my vision), so all webservices looks like:

String runSomeService(String mobyXML); // all the parsing is done 
manually inside the service.
Now let's think:
MobyMessage runSomeService(MobyMessage request); // here the parsing is 
done through the JAX-WS

My vision is that all Moby Datatypes must have a schema representation.
My generated classes being completely Moby compatible are in fact JAXB 
classes, so one can easy obtain the schema through schemagen.

WSDL 2.0 has support for ontologies using RDF for ontology hierarchy and 
XML Schema for the format description.
I am pretty sure that some of the next JAX-WS (maybe JEE7) will support it

The JAXB generated classes has the same hierarchy structure as MoSeS 
ones (both generated from the same ontology).

Let's look into example:
****************************************** JAXB version 
********************************************
@XmlRootElement(name="AnnotatedDomain")
@XmlType(name="AnnotatedDomain")
public class AnnotatedDomain extends Domain
{
    public List<BasicAnnotation> getBasicAnnotation()
    {
        return getAttributes("basicAnnotation");
    }

    public void addBasicAnnotation(BasicAnnotation basicAnnotation)
    {
        putAttribute("basicAnnotation", basicAnnotation);
    }
}

****************************************** MoSeS version 
*******************************************
public class AnnotatedDomain extends Domain
{
    private static final String DATA_TYPE_NAME = "AnnotatedDomain";
    public static final String ARTICLE_NAME_BASICANNOTATION = 
"BasicAnnotation";

    protected java.util.Vector BasicAnnotation = new java.util.Vector();

    public void set_BasicAnnotation (BasicAnnotation value)
   {
      // add an article name
      if (value != null)
          value.setName (ARTICLE_NAME_BASICANNOTATION);
      this.BasicAnnotation.addElement (value);
    }

    public void set_BasicAnnotation (BasicAnnotation[] value)
   {
      this.BasicAnnotation = new java.util.Vector();
      for (int i = 0; i < value.length; i++)
          set_BasicAnnotation (value[i]);
    }

    public BasicAnnotation[] getMoby_BasicAnnotation()
   {
        BasicAnnotation[] result_I_am_sorry_that_this_produces_a_warning 
= new BasicAnnotation [ BasicAnnotation.size() ];
        BasicAnnotation.copyInto 
(result_I_am_sorry_that_this_produces_a_warning);
        return result_I_am_sorry_that_this_produces_a_warning;
    }

    public int size_BasicAnnotation()
    {
        return BasicAnnotation.size();
    }

    public org.jdom.Element toXML()
   {
      org.jdom.Element elem_I_am_sorry_that_this_produces_a_warning = 
super.toXML();
      elem_I_am_sorry_that_this_produces_a_warning.setName (DATA_TYPE_NAME);
      for (java.util.Enumeration en = BasicAnnotation.elements(); 
en.hasMoreElements(); )
          elem_I_am_sorry_that_this_produces_a_warning.addContent ( 
((BasicAnnotation)en.nextElement()).toXML() );

      return elem_I_am_sorry_that_this_produces_a_warning;
    }

    public String toString()
   {
      StringBuffer buf_I_am_sorry_that_this_produces_a_warning = new 
StringBuffer();
      buf_I_am_sorry_that_this_produces_a_warning.append (super.toString());
      for (java.util.Enumeration en = BasicAnnotation.elements(); 
en.hasMoreElements(); )
          buf_I_am_sorry_that_this_produces_a_warning.append ( 
((BasicAnnotation)en.nextElement()).format (1) );

      return new String (buf_I_am_sorry_that_this_produces_a_warning);
    }
}
***********************************************************************************************************

As you can see the difference is:

1)
 >private static final String DATA_TYPE_NAME = "AnnotatedDomain";

@XmlRootElement(name="AnnotatedDomain")
@XmlType(name="AnnotatedDomain")

2)
 >public void set_BasicAnnotation (BasicAnnotation value)

public void addBasicAnnotation(BasicAnnotation basicAnnotation)

3)
 >public BasicAnnotation[] getMoby_BasicAnnotation()

public List<BasicAnnotation> getBasicAnnotation()

4)
 >public void set_BasicAnnotation (BasicAnnotation[] value)

// NOT IMPLEMENTED

5)
 >public org.jdom.Element toXML()

// NO NEED TO IMPLEMENT

6)
 >public String toString()

// IMLEMENTED IN THE TOP_LEVEL CLASS

As you can see there is almost no difference in both classes.
Using List instead of an array - gives a possibility to add 
BasicAnnotation in it.
Slightly different get/set method names.

Appreciate any further comments.

Dmitry



More information about the MOBY-dev mailing list