XMLBeans and JAXB

Can someone from BEA explain the relationship and/or differences between the proposed
Java standard API for XML binding, JAXB, and XMLBeans? Obviously XMLBeans offers
additional APIs, such as cursors and XQuery support (which is neat), but it seems
to be non-standard and BEA-specific.
In this context, are there any clear statements from BEA product marketing how
the technology will be productized? Without that, it seems a bit dangerous to
use...
Thanks,
PM

XMLBeans and JAX-B are complementary technologies. JAX-B is a good technology
for loading XML documents into Java objects – in constructing XMLBeans, we have
attempted to be compatible with JAX-B naming conventions. However, JAX-B cannot
necessarily preserve the full fidelity of XML documents, nor does it support 100%
of schema. This is where XMLBeans is complementary - document preservation and
support for extensibility are explicit goals of XMLBeans. Though JAX-B does not
make this possible today, it is conceivable that XMLBeans will be an implementation
of a future JAX-B spec as both technologies may converge together.
Given the above statement, one may ask then why is that preserving full fidelity
of the original XML document may be important? Consider the following advantages:
(1) Sequencing and interleaving information is not lost in XMLBeans. There are
schemas where you care whether <input> comes before <output> or <buy> comes before
<sell> or the other way around. If you just give people a Java .getBuy() and
a .getSell(), they've lost the ability to tell which came first. In XMLBeans,
after the .get you always have the ability to grab an XML cursor on the <buy>
and another one on the <sell> and ask which one came first.
(2) Information that comes into wildcards are not lost in XMLBeans. Consider
the regularly used <xsd:any> and <xsd:anyAttribute> features of schema that allow
any data to appear in the document. With JAX-B, for example, the specification
does not specify how an implementation handle content that it does not know how
to map to a Java representation. But with XMLBeans, you can see where and how
your document has been extended at the wildcards, and change or manipulate the
wildcarded data. Furthermore, something cool is that if you have compiled schemas
for the wildcarded data you can even coerce the wildcards to strongly-typed XMLBeans
and keep on drilling in conveniently. A common use case for this is processing
WSDLs: the w3c schema for WSDL uses wildcards for nearly every interesting piece
of data in a WSDL.
(3) Loading, modifying, and saving an XML document using XMLBeans, you won't lose
all the "other stuff" that human beings don't want to lose on human-readable XML
files, namely comments and all that extra pretty white space between things.
(Unless you want to lose it; XMLBeans can be put in a mode where it is used to
strip extra white space too.)
(4) The architecture is set up so that 100% of schema types can correspond one-to-one
with a Java type. This is perhaps a subtle benefit, but it is powerful because
it means that there are "no regrets" and "no dead-ends" later. You never run
into a schema type that can't be subclassed because of Java problems, or some
extension that has some data that can't be accessed from Java.
I hope this helps shed some light on the complementary relationship between XMLBeans
and JAX-B.
Regards,
Samir
"Peter Meyer" <[email protected]> wrote:
>
Can someone from BEA explain the relationship and/or differences between
the proposed
Java standard API for XML binding, JAXB, and XMLBeans? Obviously XMLBeans
offers
additional APIs, such as cursors and XQuery support (which is neat),
but it seems
to be non-standard and BEA-specific.
In this context, are there any clear statements from BEA product marketing
how
the technology will be productized? Without that, it seems a bit dangerous
to
use...
Thanks,
PM

Similar Messages

  • XmlBeans vs JAXB

    Dear friends,
    what is better? xmlbeans or JAXB ?
    I prefer JAXB because I have experience with that and also because it is a SUN specification ... but some friends here are talking about XmlBeans and I need arguments to preserve JAXB ..

    Follow these 2 threads:
    If the link is wraped to the next line, copy and paste in your browser.
    1.
    http://newsgroups.bea.com/cgi-bin/dnewsweb?utag=&group=weblogic.developer.in
    terest.xmlbeans&xrelated=34&cmd_thread_next.x=44&cmd_thread_next.y=12
    2.
    http://newsgroups.bea.com/cgi-bin/dnewsweb?cmd=article&group=weblogic.develo
    per.interest.xmlbeans&item=17&utag=
    /k
    "sudu" <[email protected]> wrote in message news:3e958c7d$[email protected]..
    >
    Hi guys,
    I just briefly read BEA's XMLBeans overview and it seems very similar (ifnot
    identical) to Sun's JAXB specification. Are they one and the same?
    Also, I am currently using the open source software from Castor(www.castor.org)
    for xml-java & java-xml translations. It seems to be a lot simpler andflexible
    than XMLBeans...
    If anyone else has used bot Castor & XMLBeans(or JAXB), i would appreciateyour
    comments...
    thanks,
    sudu

  • XmlBeans vs JAXB vs Castor

    Hi guys,
    I just briefly read BEA's XMLBeans overview and it seems very similar (if not
    identical) to Sun's JAXB specification. Are they one and the same?
    Also, I am currently using the open source software from Castor (www.castor.org)
    for xml-java & java-xml translations. It seems to be a lot simpler and flexible
    than XMLBeans...
    If anyone else has used bot Castor & XMLBeans(or JAXB), i would appreciate your
    comments...
    thanks,
    sudu

    Follow these 2 threads:
    If the link is wraped to the next line, copy and paste in your browser.
    1.
    http://newsgroups.bea.com/cgi-bin/dnewsweb?utag=&group=weblogic.developer.in
    terest.xmlbeans&xrelated=34&cmd_thread_next.x=44&cmd_thread_next.y=12
    2.
    http://newsgroups.bea.com/cgi-bin/dnewsweb?cmd=article&group=weblogic.develo
    per.interest.xmlbeans&item=17&utag=
    /k
    "sudu" <[email protected]> wrote in message news:3e958c7d$[email protected]..
    >
    Hi guys,
    I just briefly read BEA's XMLBeans overview and it seems very similar (ifnot
    identical) to Sun's JAXB specification. Are they one and the same?
    Also, I am currently using the open source software from Castor(www.castor.org)
    for xml-java & java-xml translations. It seems to be a lot simpler andflexible
    than XMLBeans...
    If anyone else has used bot Castor & XMLBeans(or JAXB), i would appreciateyour
    comments...
    thanks,
    sudu

  • Bgm.ser and jaxb.properties not created

    Is there a particular reason to why the bgm.ser and jaxb.properties files are not created when a schema only consists of a simpletype and I run the binding compiler???
    The two files seem to be created when I include a 'dummy' complextype in the schema. Is a complextype needed in order for the files to be created?
    Cheers.
    Anders
    <simpleType name="Values">
        <restriction base="string">
            <enumeration value="ValueOne"/>
            <enumeration value="ValueTwo"/>
            <enumeration value="ValueThree"/>
            <enumeration value="ValueFour"/>
        </restriction>
    </simpleType>

    I've had the same exact problem! I had the property file in my JAR file properly, but the JAXBContext.newInstance( "package.name" ) call was failing - while at the same time I could load the property file via the ClassLoader just fine, by hand.
    I played around with source for the jaxb beta a bit and I think I found the problem. I recompiled the JAR file after changing the "fileSep" variable in the "searchforcontextPath" method from "file.separatorChar" to "/".
    This seemed to fix the problem. Well, the problem of it not finding the properties file that is... now I've got some kinda non-marshalable exception (but I haven't even spent 3 minutes on that problem yet, as opposed to the hours wasted on this bug).
    I'm not sure if this bug only cropped up when running under a Windows env or not (my test was running under JBoss on XP... though I was building/compiling under Linux).
    Anyway... to fix this just change that variable.. it's on line 228 (i think... i might have added some debug lines of my own in the code) of the javax/xml/bind/ContextFinder.java file. Then just re-jar it over the old JAR -- oh yeah, you'll need a few Message.property files from the jaxb-api.jar file for the new jar file to work (so make sure you unjar the old file 1st or back it up or whatnot).

  • Xmlbean and ws8.1 ant tasks

    hi,
    i am looking to use xmlbeans to generate stubs for the input arameters and the output returned by the webservice designed using XSD schemas.
    I am not planning to use weblogic workshop and will be using only weblogic server 8.1 sp3 server to implement the webservice.
    From the weblogic server documentation I observed that using xmlbean is not supported. is that true ?
    Please provide a sample of how to integrate xmlbean and weblogic server ant tasks to implement a webservice. The ant task <autotype> generates the types.xml to be included in the wsdl file.. is there is a similar facility in xmlbeans.
    TIA
    karthik
    [[email protected]]

    Kiran,
    Did you happen to get this solution to work?
    I'm currently trying to use XMLBeans 2.x to create web services for ws8.1. My thought is that I would need to modify the types.xml to point to the XMLBeans custom serializer/deserializer class? I would then need to run the "wsdl2service" ant task to create the web-services.xml and web service implementation skeleton.
    It appears difficult to create weblogic web services outside of Workshop that use XMLBeans! Any advice that you can offer would be appreciated.
    -Shawn

  • Xmlbeans and ws8.1 ant tasks

    hi,
    i am looking to use xmlbeans to generate stubs for the input arameters and the output returned by the webservice designed using XSD schemas.
    I am not planning to use weblogic workshop and will be using only weblogic server 8.1 sp3 server to implement the webservice.
    From the weblogic server documentation I observed that using xmlbean is not supported. is that true ?
    Please provide a sample of how to integrate xmlbean and weblogic server ant tasks to implement a webservice. The ant task <autotype> generates the types.xml to be included in the wsdl file.. is there is a similar facility in xmlbeans.
    TIA
    karthik
    [[email protected]]

    Kiran,
    Did you happen to get this solution to work?
    I'm currently trying to use XMLBeans 2.x to create web services for ws8.1. My thought is that I would need to modify the types.xml to point to the XMLBeans custom serializer/deserializer class? I would then need to run the "wsdl2service" ant task to create the web-services.xml and web service implementation skeleton.
    It appears difficult to create weblogic web services outside of Workshop that use XMLBeans! Any advice that you can offer would be appreciated.
    -Shawn

  • Xmlbeans and cdata

    I have created an xmlbean, and I am storing html code in one of the elements. I am getting inconsistent results when I call the toString() method of the bean, sometimes the html is enclosed in a CDATA tag and sometimes it is not. Is there something that I can do to get consistent results. This is a critical issue for my development

    It might be in response to the length of the string (HTML) you are passing. My guess is that strings over a certain length would go as CDATA whereas others would go as Text nodes.
    http://www.mail-archive.com/[email protected]/msg00693.html
    A (partial) workaround might be here, but I did not read it fully:
    http://marc2.theaimsgroup.com/?l=xmlbeans-dev&m=111404481811361&w=2
    - Saish

  • XML and JAXB

    Hi All,
    I am planning to use Oracle XML DB 10g for persistence of XML documents and JAXB for XML-Java conversions. I would like to know
    <ul><li>     Whether this is a good approach or any better approch exists. The aim is to allow manipulation of the XML documents in XML DB tables from Java layer. </li>
    <li>What is the best way to retrieve the XMLTYPE columns using the JDBC APIs for THIN driver?</li>
    </ul>
    Thanks,
    Ramesh

    It's a bit cumbersome, but I guess as a hack , after generating your xml file, you could try just reading the input file using a regular FileReader, then writing out just the lines that start with <!doctype & <? xml > (they should be at the top right, so you know the location in the output file). Of course the efficiency for this is terrible--you're reading & writing the file all over!
    That's an interesting analogy, heh. One of the surprising things I found about JAXB is that it doesn't validate enumerations (as far as I know).

  • JAXM and JAXB

    How can I use JAXM and JAXB togather to build an web service application?
    Actually, I don't know how to use XML exported by Marshaller method marshal() for JAXM.
    Can you give some sample code?
    Thanks.

    There's a huge tutorial (19 chapters and 7 appendices) with the JavaTM Web Services Developer Pack 1.1 - it includes masses of samples applications.
    All the best,
    Fergus.

  • Web Service Object Parameters and JAXB

    Hi All,
    This is my first post here and I'm hoping one of you might have encountered a similar problem before. One of our business partners provided us with a WSDL for their service, with an embedded XML schema. My job in this case is to write a message driven bean (MDB) that will take a message containing XML off of a queue and call this web service. However, their web service requires an object to be passed as input. So, I've used JAXB to generate a set of classes (from the schema I ripped out of their WSDL) that will unmarshal the XML document that comes off the queue. This works fine, however, the resulting object is an inherently different object than the object I need to pass to the web service, that one was created by auto-generating the Java proxy for the web service. Since these two classes come from the same schema definition, they have the same structure and can hold the same data, but they have different implementations. My plan is to write a method to copy the data from one object to another, but this feels redundant. Is there any approach I could use to make these two auto-generated sets of code be more compatible, other than the obvious answer of having written everything by hand? Thanks in advance for any replies.

    Are the XML instances coming from the queue and the request object to the WS defined by the same schema (from the business partner)? If they are different, there's no other option than to do a copy or some sort of XSLT (not that that's any easier though). But if the instances are defined by the same schema, just use some data binding framework that you can use for both reading the XML from the queue and that is incorporated into the WS toolkit you're using.
    For example, Axis2 allows you to use XMLBeans as a the data binding framework. Using the generated classes from Axis2, you can read in the XML instances from the queue and at the same time have the request object for the WS call.

  • JSP and JAXB

    DB Structure
    Parent Table - Incident --> Child Table - IncidentCharges --> Child Table of IncidentCharges --> IncidentChargeWeapons
    Container
    Oracle Containers for JAVA(OC4J)
    We have a schema (Incident.xsd) which comprises of our entire database structure. We unmarshalled the schema using JAXB to Java classes and interfaces .
    It created 2 .java classes and 2 .java interfaces for each high level tag . for eg for our Incident tag it created a Incident interface and a IncidentType Interface
    and also it created 2 classes IncidentImpl and IncidentTypeImpl . The IncidentTypeImpl has all the get and set properties we require eg. getIncidentType,
    setIncidentType,getIncidentNumber,setIncidentNumber,getOccuranceDate,setOccuranceDate etc.
    Our objective is to create a JSP page which has form fields to enter data which use these JAXB generated classes get and set properties. In other words
    we want to bind the JSP form fields to these JAXB generated classes. And once these JAXB objects are populated we want to marshal it and create a XML file with the data from those JAXB . Our database would then consume the generated XML. We tried creating a simple incident form with just 3 fields IncidentType,Occurance date and Incident Number and tried to bind these fields with the properties from IncidentTypeImpl classes using the <jsp:usebean> tag . When we deployed it to our container and tried to load the Incident.jsp page , it would not load up . Only when we cleared all the bindings it loaded up .
    Then we tried another workaround (just to get it working. Not a preferred approach) . We created another simple JAVA bean(not JAXB generated beans) which has set and get properties for the form fields and bound the form fields to it.
    On submitting the JSP page we called a servlet which takes data from our created bean and transfers it to the JAXB generated IncidentTypeImpl bean. When we deployed this the jsp page loads up and also our bean is filled with data . But the servlet bombs with this error below.
    500 Internal Server Error
    java.lang.NoClassDefFoundError: javax/xml/bind/JAXBContext
    at Servlets.IncidentServlet.doPost(Unknown Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:765)
    at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
    at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
    at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)
    at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
    at com.evermind[Oracle Application Server Containers for J2EE 10g (9.0.4.0.0)].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
    at java.lang.Thread.run(Thread.java:534)
    We have 2 questions .
    1. Can a JSP page be bound directly to this JAXB generated bean in pretty much the same way as we bind it to our own bean ? (We would like to do this so that we dont have to create duplicate classes which mirror the JAXB generated classes.)
    2. Is there something special we have to do to deploy this application to recognize the JAXB classes. Do we have to deploy some jar file for it to recognize those classes ?

    I've used oracle's xdk to generate both the interfaces and the implementation classes. Next i've implemented a service class with some methods to return java classes as generated by oracle's jaxb. The return types of these service methods are interfaces, not the implementation classes.
    I can generate an adf data control for this service class, but the data control palette doesn't show the attributes for the jaxb generated classes (i have changed the bean class property in the data control description xml file).
    It's not possible to ignore the interfaces and just use the implementation classes, as the implementation classes specify their return types in interfaces. I don't want to rewrite all the generated code.

  • Dynamic class loading issue with XmlBeans and Axis2

    Hi,
    Since support to web services is not enough in JDeveloper I am using apache axis2 to consume web services from an ADF web application.
    Everything works fine if I use jdk 1.5 but our app servers require jdk 1.4.2_08-b03 so I switched jre settings to jdk 1.4.2_08-b03 in the JDeveloper and I started to get these issues.
    I debugged the application and this line is the cause of the exception. It is in request document class.
    return (org.htng.pws._2008a.guestselfservice.name.types.FetchProfileRequestDocument)org.apache.xmlbeans.XmlBeans.getContextTypeLoader().newInstance(type,
    null);
    I did some further testing and found that it is happening when I call org.apache.xmlbeans.XmlBeans.getContextTypeLoader()
    The error messages that I am getting are
    1.     J*BO-29000: Unexpected exception caught: java.lang.IllegalAccessError, msg=tried to access field* org.htng.pws._2008a.guestselfservice.name.types.FetchProfileRequestDocument$1.class$org$htng$pws$_2008a$guestselfservice$name$types$FetchProfileRequestDocument from class org.htng.pws._2008a.guestselfservice.name.types.FetchProfileRequestDocument
    2.     tried to access field org.htng.pws._2008a.guestselfservice.name.types.FetchProfileRequestDocument$1.class$org$htng$pws$_2008a$guestselfservice$name$types$FetchProfileRequestDocument from class org.htng.pws._2008a.guestselfservice.name.types.FetchProfileRequestDocument
    As I understand somehow the application server is not allowing the XMLBeans APIs to dynamically load the classes ..But I couldn’t find a way to convince it..
    Does anybody have any idea by any chance?
    Thanks a lot

    Some more details ..
    I could make it work if I change the below getClassLoader with Thread.currentThread().getContextClassLoader()
    org.apache.xmlbeans.XmlBeans.typeSystemForClassLoader(FetchProfileResponseDocument.class.getClassLoader()This is a generated code and normally works fine with jdk 1.5 .. I guess there should be some setting to make it work in 1.4 as well..
    Any Idea ?

  • JAXB 1.0 and JAXB 2.0 APIs

    Hi, Folks.
    I've just inherited a test application that was written using JAXB 1.0. The application it tested has since moved onto JAXB 2.0 but the test application has lain dormant for the last 12 months. I now have the task of bringing the test application up to date and as you might expect, I am seeing lots of errors. I need to figure out how to convert the old to the new but all my searches for a JAXB 1.0 javadoc API document have failed. Does someone know where I can find this please?
    Thanks, Max

    Maybee here
    http://java.sun.com/webservices/docs/1.4/api/index.html

  • Add java classes as Additional Classes to web service and JAXB 2.0 usage

    Hi,
    I start using JDeveloper 11g TP3 to create web service. I encounter two problems.
    1. I created a schema file as the following,
    <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://FromWSDL/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:tns="http://FromWSDL/">
    <xsd:complexType name="sayHello">
    <xsd:sequence>
    <xsd:element name="arg0" type="xsd:string" default="Tommy"/>
    <xsd:element name="arg1" type="tns:arg1Enum"/>
    </xsd:sequence>
    </xsd:complexType>
    <xsd:simpleType name="arg1Enum">
         <xsd:restriction base="xsd:string">
         <xsd:enumeration value="preserve"/>
         <xsd:enumeration value="replace"/>
         <xsd:enumeration value="collapse"/>
         </xsd:restriction>
    </xsd:simpleType>                         
    <xsd:element name="sayHello" type="tns:sayHello"/>
    <xsd:complexType name="sayHelloResponse">
    <xsd:sequence>
    <xsd:element name="return" type="xsd:string"/>
    </xsd:sequence>
    </xsd:complexType>
    <xsd:element name="sayHelloResponse" type="tns:sayHelloResponse"/>
    </schema>
    then I used TopLink/JPA-->JAXB 2.0 Content Model from Schema, I got four java files: Arg1Enum.java, ObjectFactory.java, SayHello.java, and SayHelloResponse.java.
    After, I create a java class with @WebService and @WebMethod annotation. Right Click on the web service class,
    select Web Service Properties-->Additional Classes, I added the four java classes. but there are error message for SayHello and Arg1Enum
    "the type SayHello cannot be serialized into XML and no custom serilizer has been defined for it"
    2. In JDeveloper, I create Java model from the above schema, then reverse the steps, create a new schema from Java Model, the original schema and the schema from Java Model are not same, especially for "defaultValue" and "required" fields for the custom element(SayHello and Arg1Enum).
    Any help will be appreciated

    First what you mean by "deploying classes as web services"? Chances are you
    can do it with something like Glue from The Mind Electric ... but chances
    are that you don't want to. What are you trying to accomplish?
    Peace,
    Cameron Purdy
    Tangosol, Inc.
    Clustering Weblogic? You're either using Coherence, or you should be!
    Download a Tangosol Coherence eval today at http://www.tangosol.com/
    "Simon Wallis" <[email protected]> wrote in message
    news:[email protected]..
    Hi, can WebLogic deploy simple Java classes (not EJB's or JB's, just
    classes) as a web service? How easy it is to do?
    The WebLogic installation has one measly web services example, and it's an
    EJB which is not what I want to do.
    Thanks,
    Simon.

  • Restriction and the Fixed attribute and JAXB

    Hi
    I have what I believe is a valid XSD, with two complex types BaseType and OtherType. What I want is for BaseType (abstract) to have an attribute but no fixed value for it. OtherType would restrict the allowable values to just "Test". I have checked the XSD with xmlspy and the W3C site.
    so happy with the xsd I try to use JAXB to generate classes:
    xjc.bat -p com.me.test example.xsd -d gen
    but I get :
    [ERROR] derivation-ok-restriction.2.1.1: Error for type 'OtherType'. An attibute use in this type has a REQUIRED setting which is inconsistent with a matching attribute use in the base type.
    (removing the Fixed attribute solves it but I'd like to keep it)
    Any ideas?
    Thanks
    Des Field Corbett
    XSD Follows:
    ================================================================================
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xs:complexType name="BaseType" abstract="true">
    <xs:attribute name="name" type="xs:string" use="required"/>
    </xs:complexType>
    <xs:complexType name="OtherType">
    <xs:complexContent>
    <xs:restriction base="BaseType">
    <xs:attribute name="name" fixed="Test"/>
    </xs:restriction>
    </xs:complexContent>
    </xs:complexType>
    <xs:element name="root" type="OtherType"></xs:element>
    </xs:schema>

    Got it to work...
    My XSD had the line in BaseTypes:
    <xs:attribute name="name" type="xs:string" use="required"/>
    and the line in OtherTypes:
    <xs:attribute name="name" fixed="Test"/>
    Changing this to:
    <xs:attribute name="name" type="xs:string" use="required" fixed="Test"/>
    Got it to work.
    Not sure if this is a Bug in JAXB or its just being fussy... Sure going to make it a pain to hand code in the extra tags in to my real life XSD!
    If there is a better way I'd be grateful to know....
    Thanks
    Des
    BTW getting a java.lang.reflect.InvocationTargetException now - but as I'm just learning JAXB so I'm guessing thats something else.

Maybe you are looking for