Use JAXB unmarshalling in Weblogic Server

Posted by Leo on Stack Overflow See other posts from Stack Overflow or by Leo
Published on 2010-12-23T18:11:39Z Indexed on 2011/01/06 2:53 UTC
Read the original article Hit count: 455

Filed under:
|
|
|
|

Especifications: - Server: Weblogic 9.2 fixed by customer. - Webservices defined by wsdl and xsd files fixed by customer; not modifications allowed.

Hi,

In the project we need to develope a mail system. This must do common work with the webservice. We create a Bean who recieves an auto-generated class from non-root xsd element (not wsdl); this bean do this common work. The mail system recieves a xml with elements defined in xsd file and we need to drop this elements info to wsdlc generated classes. With this objects we can use this common bean. Is not possible to redirect the mail request to the webservice.

We've looking for the code to do this with WL9.2 resources but we don't found anything. At the moment we've tried to use JAXB for this unmarshalling:

JAXBContext c = JAXBContext.newInstance(new Class[]{WasteDCSType.class});
Unmarshaller u = c.createUnmarshaller();
WasteDCSType w = u.unmarshal(waste, WasteDCSType.class).getValue();

waste variable is an DOM Element object. It isn't the root element 'cause the root isn't included in XSD

First we needed to add no-arg constructor in some autogenerated classes. No problem, we solved this and finally we unmarshalled the xml without error Exceptions. But we had problems with the attributes. The unmarshalling didn't set attributes; none of them in any class, not simple attributes, not large or short enumeration attributes. No problem with xml elements of any type.

We can't create the unmarshaller from "context string" (the package name) 'cause not ObjectFactory has been create by wsldc. If we set the schema no element descriptions are founded and unmarshall crashes.

This is the build content:

<taskdef name="jwsc" classname="weblogic.wsee.tools.anttasks.JwscTask" />
<taskdef name="wsdlc" classname="weblogic.wsee.tools.anttasks.WsdlcTask"/>    

 <target name="generate-from-wsdl">
        <wsdlc
            srcWsdl="${src.dir}/wsdls/e3s-environmentalMasterData.wsdl"
            destJwsDir="${src.dir}/webservices"
            destImplDir="${src.dir}/webservices"
            packageName="org.arc.eterws.generated"
            />
        <wsdlc
            srcWsdl="${src.dir}/wsdls/e3s-waste.wsdl"
            destJwsDir="${src.dir}/webservices"
            destImplDir="${src.dir}/webservices"
            packageName="org.arc.eterws.generated"
            />
    </target>

<target name="webservices" description="">
        <jwsc srcdir="${src.dir}/webservices" destdir="${dest.dir}" classpathref="wspath">
            <module contextPath="E3S" name="webservices">

                <jws file="org/arc/eterws/impl/IE3SEnvironmentalMasterDataImpl.java"
                        compiledWsdl="${src.dir}/webservices/e3s-environmentalMasterData_wsdl.jar"/>

                <jws file="org/arc/eterws/impl/Ie3SWasteImpl.java"
                        compiledWsdl="${src.dir}/webservices/e3s-waste_wsdl.jar"/>

                <descriptor file="${src.dir}/webservices/META-INF/web.xml"/>
            </module>

        </jwsc>
</target>

My questions are:

  • How Weblogic "unmarshall" the xml with the JAX-RPC tech and can we do the same with a xsd element?
  • How can we do this if yes?
  • If not, Exists any not complex solution to this problem?
  • If not, must we use XMLBean tech. or regenerate the XSD with JAXB tech.? What is the best solution?

NOTE: There are not one single xsd but a complex xsd structure in fact.

© Stack Overflow or respective owner

Related posts about java

Related posts about xsd