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

Dmitry Repchevsky dmitry.repchevski at bsc.es
Wed Jan 16 15:57:20 UTC 2008


Hello,

I will try to answer the questions as deep as I can.

> I know, but I can't create the data tag using a QName with the version 
> of JAX-WS on the Sun Web site.  The Java SE6 version allows me to (this 
> is needed to declare the xsd namespace, since createName does not 
> stupidly allow manual declarations in the xmlns namespace).  It's funny 
> how javax.xml.ws doesn't work the same in both versions...if you can 
> figure out how to declare a namespace manually in a SOAPMessage without 
> QName, let me know!

I  use the same method!!!
Look into AbstractMobyEndpoint.createSoapMessage().
**********************************
env.addNamespaceDeclaration("xsd", "http://www.w3.org/2001/XMLSchema");
**********************************
is this what you mean?

> Okay, but when you work without the data types, JAXB creates an 
> AnyMobyObject?

Exactly. When JAXB can not find appropriate datatype it passes it as an 
Element (look into MobySimple.setJaxbObject()).
So I marshall/unmarshall it into AnyMobyObject. This way you can use 
same API to work both with AnyMobyObject or datatypes objects (and can 
mix it).
ALL the data stored in top-level class (MobyObject) so you can work with 
it without using get/set methods.
This way "datatypes" are only getters/setters for the "attributes".

you can either call
List<BasicAnnotation> list = annotatedDomain.getBasicAnnotation();
or
List<AbstractMobyObject> list = mobyObject.getAttributes("basicAnnotation");

in latter case list would contain BasicAnnotation or AnyMobyObject 
depending if datatype was found by jaxb.

For example in demo application I make drag and drop of OBJECTS (from 
right panel).
If you put datatypes.jar in CLASSPATH so actual object will be the 
"real" one (for example PDB_Text), if not - it will be "AnyMobyObject".
> >/ My vision is that all Moby Datatypes must have a schema representation.
> /As far as I can recall, this is not possible (others can correct me if 
> I'm wrong, or these have been solved) .
Well since JAXB MUST generate schema from valid JAXB classes... Another 
thing is how good the schema would be (I'm not the greatest schema 
specialist :-))
Just look into the schema for the AnnotatedDomain class:
*******************
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:element name="Ace_Text" type="Ace_Text"/>

  <xs:element name="Object" type="mobyObject"/>

  <xs:element name="text-formatted" type="text-formatted"/>

  <xs:element name="text-plain" type="text-plain"/>

  <xs:complexType name="Ace_Text">
    <xs:complexContent>
      <xs:extension base="text-formatted">
        <xs:sequence/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="text-formatted">
    <xs:complexContent>
      <xs:extension base="text-plain">
        <xs:sequence/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="text-plain">
    <xs:complexContent>
      <xs:extension base="mobyObject">
        <xs:sequence/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="mobyObject">
    <xs:sequence>
      <xs:any processContents="lax" namespace="##other" minOccurs="0" 
maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attribute name="articleName" type="xs:string"/>
    <xs:attribute name="id" type="xs:string"/>
    <xs:attribute name="namespace" type="xs:string"/>
  </xs:complexType>
</xs:schema>
*******************

> The main sticking points were 
> that if an object is a Moby Primitive in a has relationship, it cannot 
> be represented in XML schema.

Don't get this one... ?

> Also, I think that the fact that we must 
> be able to accept subclasses of declared classes, even if we don't know 
> about them, causes another problem.

JAXB can do it... It's called type substitution. I don't like the way it 
works...
I my case it substituted by AnyMobyObject. Technically it's possible to 
implement some heuristic BEFORE parsing to it.
I could look into known objects (To have this information I implemented 
a custom classloader for Jaxb loaded classes) and if there is some that 
matches by parameters... not sure how to do it yet...

Regards,

Dmitry




More information about the MOBY-dev mailing list