Originally posted by sulbha walawalkar:
Which design pattern can be used with facade to keep business logic to form xml and call 3rd party api to read/write data to SQL server?
am using jaxb as marshaller and thinking of using the same to form xml message to send to 3rd party api.
Is there any other good way of forming xml from xsd?
1. while using marshaller, I have created request objects from xsd file (contract-first) which are exposed to client in wsdl.
Should I use/pass the same request objects to servic layer?
Or create diffrent domian objects in servic layer and pass thar to facade/service?
2. Application will also write some of the data to DB2..for which I have written DAO. since no business logic should be kept in facade, I have written that bit of code in DAO. Does that sounds logical?
3. To read/write data in xml from java objects, I think I need to again map the xsd file (provided by third party) to java objects and use apis (from jaxb/xml beans or any other xml tech) to translate the data into xml and vice versa... I am not sure which pattern would be good to implement this bit of code.
Originally posted by Peer Reynders:
[QB]
You should be able to do most of the XML/Java conversion through the use of external binding files. Then it is simply a matter of layering the responsibilities appropriately.
Thanks for thr reply. As of now I'm doing the 2nd option to created DTOs from schema objects. I'll look at the external binding option for jaxb. Is there any binding mapping that I need to configure in spring servlet xml file or while binding schema? Could not find any example for that.
About the converting the java objects to xml, yes I can use Adapter to translate the data in xml.
I tried to create the java objects with jaxb1, but the xsd file has <xs:redefine> tags which are not supported by jaxb1. Jaxb2 does support, but we have jaxb1 marshalling/unmarshalling jars being used by other applications. Not sure when they will upgrade to jaxb2. So I cant use jaxb2 as of now.
I'll be implementing castor for soap message & converting java to xml as another approach to test the performance.
Is there any better option to transalte java to xml (with jaxb1 for marhalling/unmarshalling soap message)?
Also if I have <xsd:redefine> in xsd file, the code generator doesn't generate java class with the name of xsd file. Instead it generates java classes for as many xsd files I have in <xsd:redefine> tag. Not sure how to generate xml out of so many classes. I believe any marshal method accepts xml file name & java class containing the data.
Thanks,
Sulabha
Originally posted by sulbha walawalkar:
I'll look at the external binding option for jaxb. Is there any binding mapping that I need to configure in spring servlet xml file or while binding schema? Could not find any example for that.
I tried to create the java objects with jaxb1, but the xsd file has <xs:redefine> tags which are not supported by jaxb1.
Is there any better option to translate java to xml (with jaxb1 for marhalling/unmarshalling soap message)?
External binding happens during compile time with the xjc compiler - so I don't see that having any impact on the deployment settings.
It may be worth looking at "pre-processing" those redefines out the schemas (people having to deal with them don't seem too fond of them) for JAXB - i.e. replacing the redefines with an "include" to a new schema file that is generated from the "original redefined" schema with all the redefinitions applied. JAXB won't care as long as the fully qualified names aren't affected.
Originally posted by Peer Reynders:
[QB]
Performance wise Castor is inferior to both versions of JAXB. It is also unclear how long Castor will be supported with JAXB being part of the JDK. The current non-JAXB favorite seems to be JiBX and it is supported by Axis 2. With JiBX you can sidestep the JAXB upgrade issue and possibly use Axis 2 as your front end. JiBX seems to have the best performance characteristics.
Originally posted by sulbha walawalkar:
Were you suggesting external binding for mapping the xsd to domain objects?
I could create the objects with Jaxb2
code:
---------------------------------------------------------------------------
Web serviceRequest Response=========== ==========JAXB ^^^^^^^^^^XML to Obj JAXB Use external bindings to map Objects to and from XML (Schema)vvvvvvvvvv Obj to XML============ =========== Domain Logic Objects============ =========== Object-based SQL Server facadeObj to XML ^^^^^^^^^^translators XML to Obj JAXB assisted marshalling/unmarshallingvvvvvvvvvv translators possibly using your own XML Schemas========== ==========XML-based SQL Server API
---------------------------------------------------------------------------
Quick! Before anybody notices! Cover it up with this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|