Antoni,

please see inline.

Alatalo, Antoni wrote:
You are absolutely right about schemas that are properly maintained.
It's the key for all. The problem is what is right. I can't say that
I'm expert to write xml schemas, but I have some experience to do it.
Schema may be ok and it validates against specifications and still
there may be some things that should be done better.

Generating code from schemas - I like generating, but also I like to
have control of what I'm writing. Generate once and then write you
own code inside - usually there is no back way to generate something
again. XML schema <--> POJO <--> Hibernate xml mapping files. Where
is the point of generating? Also XML Scehema structure != POJO
structure != Database structure. So the generating is not the way I
want to use.
I somewhat agree with you that one should keep things apart and not assume that there will be a solution that does not require some manual intervention.

Axis2 generated code smells - mean that I don't like it at all.
Do do I. I would never use Axis (and its generation feature) again to have POPOs for my project(s) generated. But here's where I tried to make my point. Don't use Axis(2) to generate your domain object, but refer this task to a tool (such as Castor is) that generates something useful. And Castor definitely is useful in this context, as it created vanilla POJOs from an XML schema.

It creates some more (namely descriptor classes, as they are required for XML data binding), but the POJOs created are kept as is. Java properties, getter/setter methods, end of story.

Thus, you can still go and define your Hibernate mapping files for these POPOs. And as far as I can tell, the POJOs generated are as simple as can be: plain old Java.


Generate server side and client side. At the client side you have all
classes as inner classes in stub. Same clessas are generated in
server side generating separately. Generated not always is the same
as wsdl describes.
As already said, don't use a WS-framework for creating domain objects from the SWDL (XML schemas defined/used therein).

ReceiverInOut and stub has a lot of if else
redundance code. toOm fromOm toEnvelope are not always correct. I
think that's enough reasons.


Regards. Antoni

-----Original Message----- From: Werner Guttmann
[mailto:[EMAIL PROTECTED] Sent: 10. huhtikuuta 2008 12:51 To:
[email protected] Subject: Re: [castor-user] How to use
hierarchical objects with wrapper

HI,

some random observations.

Alatalo, Antoni wrote:
Hi, It's all about WS.

We have at the backside domain model implemented on java. We also
have the same model in xml schema. It's so easy to use once
implemented schemas and java code together.

So we have some set of web services witch requires of course xml schemas. When schemas are standard, then them reuse is simple.

We are currently using Axis2 for WS implementation. The problem is generated code, wich smells ...
Can you make that a bit clearer for me ? Just saying 'it smells' does
not provide enough information for me to fully understand what you
are trying to say.

and also generates again and again same classes for different services.
Why would that be the case ? If you maintained your XML schemas
properly (and you are in control of writing them), you can always
reuse XML schema definitions (whether through includes or imports) to
build up more complex XML schema, which then are used within a WSDL
to define the types of the XML payload.

So we want to move to the next level. Seems that spring ws + castor
is right solution.
Which is something I'd definitely consider myself.
No any more generated code but simple nice code.
The problem in my view is not that you generating code, per se. As
explained above, maintaining your XML schema properly is the key
requirement. From this, create your domain objects once (and once
only), and use them throughout your system; that's for e.g.
(un)marshalling XML, persistence, etc. You name it.

The other side why not generate xml schemas from code or backward
are other standard schemas that are not in our hands. Those are for
 example SAML, SPML, ... They has own implementations and
stanardiseded schemas and there is no way or reason why we event
think to generate something.
Why ? I have got some big clients that generate some odd 1200 classes
from e.g. the FpML standard, and then use them as their domain
objects in their systems. What's wrong about this approach ?


Regards Antoni

-----Original Message----- From: Werner Guttmann [mailto:[EMAIL PROTECTED] Sent: 10. huhtikuuta 2008 12:19 To: [email protected] Subject: Re: [castor-user] How to use hierarchical objects with wrapper

Before looking into this in more detail, I have got a question: you
 seem to have an XML schema. Why don't you generate the Java
classes (and the corresponding descriptor classes) from the XML
schema (using the XML code generator) and let Castor take care of
the rest ?

I have never understood why somebody would want to use a mapping
file when there's an XML schema available.

Werner

Alatalo, Antoni wrote:
Hi, Here is all in nutshell: SCHEMA: <?xml version="1.0" encoding="UTF-8"?> <schema xmlns="http://www.w3.org/2001/XMLSchema"; targetNamespace="http://example.com/foo"; xmlns:tns="http://example.com/foo";
elementFormDefault="qualified"> <complexType name="fooType">
<sequence> <element name="children" minOccurs="0"> <complexType>
<sequence> <element name="child" type="tns:fooType"
maxOccurs="unbounded"> </element> </sequence> </complexType>
</element> </sequence> <attribute name="name"></attribute>
</complexType> <element name="foo" type="tns:fooType"></element>
</schema>

CASTOR <?xml version="1.0"?> <!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN" "http://castor.org/mapping.dtd";> <mapping> <class name="com.example.Foo" auto-complete="false"> <map-to xml="foo" ns-uri="http://example.com/foo"; ns-prefix="foo" /> <field name="name" type="java.lang.String"> <bind-xml name="name" node="attribute" /> </field> <field name="children" collection="collection" type="com.example.Foo" container="false">
 </field> </class> </mapping>

BEAN package com.example; import java.util.Collection;

public class Foo { private String name; private Collection<Foo> children;

public Foo(){} public Foo(String name){ setName(name); } public Collection<Foo> getChildren() { return children; } public void setChildren(Collection<Foo> children) { this.children = children;
} public String getName() { return name; } public void
setName(String name) { this.name = name; } }


TESTCASE: package com.example;

import java.io.IOException; import java.io.StringReader; import java.io.StringWriter; import java.util.Collection; import java.util.HashSet;

import junit.framework.TestCase; import org.exolab.castor.xml.XMLContext; import org.exolab.castor.mapping.Mapping; import org.exolab.castor.mapping.MappingException; import org.exolab.castor.xml.MarshalException; import org.exolab.castor.xml.Unmarshaller; import org.exolab.castor.xml.Marshaller; import org.exolab.castor.xml.ValidationException;

import com.example.Foo;

public class CastorFooTest extends TestCase { Mapping mapping =
null; XMLContext context = null; public void setUp() throws
IOException, MappingException{ mapping = new Mapping(); mapping.loadMapping("src/META-INF/castor/foo-castor.xml");
context = new XMLContext(); context.addMapping(mapping); } public
void testMarhallFoo() throws IOException, MappingException, MarshalException, ValidationException{ Marshaller marshaller = context.createMarshaller(); StringWriter writer = new
StringWriter(); marshaller.setWriter(writer);
marshaller.setMarshalAsDocument(false); marshaller.setMapping(mapping); marshaller.setSuppressNamespaces(false); marshaller.marshal(getFoo()); assertEquals(expected, writer.getBuffer().toString()); } public void testUnMarhallFoo() throws IOException, MappingException, MarshalException, ValidationException{ Unmarshaller unmarshaller = context.createUnmarshaller(); StringReader reader = new StringReader(expected); Foo result = (Foo)unmarshaller.unmarshal(reader); Foo exp = getFoo(); assertEquals(exp.getName(), result.getName()); } private Foo getFoo(){ Foo foo = getFoo(""); Collection<Foo> children = new HashSet<Foo>(); children.add(getFoo("2"));
children.add(getFoo("1")); foo.setChildren(children); return foo;
}  private Foo getFoo(String s){ Foo foo = new
Foo("foo".concat(s)); return foo; } private String expected =
"<foo:foo xmlns:foo=\"http://example.com/foo\"; name=\"foo\"><foo:children><foo:foo name=\"foo1\"></foo:foo><foo:foo name=\"foo2\"></foo:foo></foo:children></foo:foo>"; }


Expected output <?xml version="1.0" encoding="UTF-8"?> <foo:foo name="foo" xmlns:foo="http://example.com/foo";> <foo:children> <foo:foo name="foo1"/> <foo:foo name="foo2"/> </foo:children> </foo:foo>

OUTPUT I GET: <?xml version="1.0" encoding="UTF-8"?> <foo:foo name="foo" xmlns:foo="http://example.com/foo";> <children> - ERROR NUMBER 1 <foo:foo name="foo1"> <children /> - ERROR NUMBER 2 </foo:foo> <foo:foo name="foo2"> <children /> - ERROR NUMBER 2 </foo:foo> </children> - ERROR NUMBER 1 </foo:foo>

Output I get isn't valid: 1. <children> element must have foo
prefix as all others: <foo:children> 2. there must not be empty
<children/> element at all

Regards. Antoni

-----Original Message----- From: Werner Guttmann [mailto:[EMAIL PROTECTED] Sent: 9. huhtikuuta 2008 15:13
To: [email protected] Subject: Re: [castor-user] How to
use hierarchical objects with wrapper



Alatalo, Antoni wrote:
Hi, I have Object A that has Collection of Objects A. Normal hierarchy structure. I got to work it almost well except two details. The collection is wrapped. It should look like this
Lets name namespace like bar <bar:foo name="1"> <bar:children>
<bar:foo name="2*"*/> <bar:foo name="3"/> </bar:children>
</bar:foo>

The problem is that chioldren while marhalling doen't get bar prefix. This is output after marshalling <bar:foo name="1"> <children> <bar:foo name="2*"*> <children/> </bar:foo> <bar:foo
 name="3"> <children/> </bar:foo> </children> </bar:foo>

How can i configure mapper to use prefix with "children"
wrapper? Without this xml is not valid!
What version of Castor are you using ? And what does your mapping
for the relevant classes look like ? It looks like you are using
the locations attribute on the field mapping for the 'bar'
children ?

Teh next thing is empty collection. How can i configure mapper
to exclude empty or null not required values?
Can you show us some sample XML that highlights your problem ? It
 just isn't fully clear to me what the problem is.

Thank you *Antoni Alatalo *Ohjelmistoasiantuntija
Kuntatoimiala, sosiaalitoimi
_________________________________________

*Logica **- Releasing your potential

*Karvaamokuja 2 PL 38 00381 Helsinki Vaihde: 010 302 010 Suora:
040 583 1097 [EMAIL PROTECTED] _www.logica.fi_ <http://www.logicacmg.fi> WM-datan nimi on nyt *Logica.*


---------------------------------------------------------------------
 To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email




---------------------------------------------------------------------
 To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email




---------------------------------------------------------------------
 To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email




---------------------------------------------------------------------
 To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email





---------------------------------------------------------------------
 To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email




---------------------------------------------------------------------
 To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email





---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to