Question

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.

Was it helpful?

Solution

If the XSD that specifies the xml the mail server is receiving is the same (either literally, by being the same file(s) or semantically by having the same fully qualified names) as the xsd included in the wsdl, then the jaxb generated classes should be able to be passed straight in.

If not, then the xml blob from the mail service is simply NOT capable of being sent straight into the webservice. But that's ok, that's what your broker bean is for.

You unmarshall the xml as you are doing, then you manually construct a new object (the wsdl generated jaxb object) based on the mail server unmarshalled object.

I understand that the objects (mail and webservices) might be logically the same, and you're hoping for some magic glue, but XML is a lot stricter than that.

If you're trying to use a JAXB unmarshaller from the web services generated classes to unmarshall XML from the mail service, again, this will totally fail if the schemas are not identical

Remember, and this is important, the following two xml snippets are NOT the same, no matter how much you might want them to be.

<blob xmlns="urn:mailserver.schema.generated">
   <from>blah</from>
   <to>wop</to>
   <message>this is a message</message>
</blob>

<blob xmlns="urn:webservice.wsdl.generated">
   <from>blah</from>
   <to>wop</to>
   <message>this is a message</message>
</blob>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top