You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by "Heemskerk, Marcel (M.)" <Ma...@uwv.nl> on 2008/07/14 16:23:33 UTC

Flexible XSD / XML generator

We have the requirement for a web service to respond XML in a flexible
format (flexible XSD) and i am looking to see if i can use internal CXF
classes for this. 

The web service exposes a complex and very large database read-only. For
every consumer a database view is generated, based on priviledges to see
certain columns and rows.  Then, every service consumer can define how
the data should be represented in XML. For example, the relation Order
-> OrderLine -> Book can be represented as one XML tree with all three
objects or as two XML trees with Order-> OrderLine  and one with Books.
See examples below.

This means that the XSD and XML is flexible and different per consumer.
Over a hundred consumers exist.

The XSD/WSDL should generated and XML produced without restarting or
programming the application. 

Any suggestions to how to solve this with CXF ?

JAXB is out-of-question (because XSD generation is at developtime),
which XML binding framework is best suited for this? 





Simple one XML tree:


<Order>
	<OrderLine>
		<Book id="100">
			<Title>Hitchhikers Guide</Title>
		</Book>
		<Quantity>1</Quantity>
	</OrderLine>
	<OrderLine>
		<Book id="200">
			<Title>CXF Guide</Title>
		</Book>
		<Quantity>2</Quantity>
	</OrderLine>
</Order>

Or as two XML trees like this:


<Order>
	<OrderLine>
		<BookId>100</BookId>
		<Quantity>1</Quantity>
	</OrderLine>
	<OrderLine>
		<BookId>200</BookId>
		<Quantity>2</Quantity>
	</OrderLine>
</Order>
<Books>
		<Book id="100">
			<Title>Hitchhikers Guide</Title>
		</Book>
				<Book id="200">
			<Title>CXF Guide</Title>
		</Book>
</Books>





Met vriendelijke groet,
Marcel Heemskerk
Software Architect Polis+ Webservices


Re: Flexible XSD / XML generator

Posted by Sergey Beryozkin <se...@iona.com>.
Hi

If your requirement is to use SOAP (with WSDL being generated) then Aegis Binding is something you may want to look at. I'm not sure it can hande all the requirements but you might be able to progress if you do some kind of transient endpoint publications with WSDL dynamically generated per every endpoint...Actually - it probably won't work given that XSDs will be created before. Perhaps just plain JAX-WS with failrly generic WSDL and a lots of EPRs will do.

However, given the highly dynamic nature of the data, the RESTful approach may be easier to adopt for this case.
Have a look at the CXF JAX-RS documentation and see if you can adopt the JAX-RS approach. For ex, you might be able to use Atom/AtomPub - with per-client Atom instance/representations providing client-specific links for users to explore their 'views' further...As far as the interface description is concerned you may be able to just rely on Atom Service documents - or indeed you can generate WADL documents on a per-resource basis - this is not something CXF JAX-RS can do (Jersey can for ex) but it would be possible to implement such WADL handlers now that fiters are supported in CXF JAX-RS.

Perhaps you'll be able to combine both approaches too....

Cheers, Sergey


----- Original Message ----- 
From: "Heemskerk, Marcel (M.)" <Ma...@uwv.nl>
To: <de...@cxf.apache.org>
Cc: "Heemskerk, Marcel (M.)" <Ma...@uwv.nl>
Sent: Monday, July 14, 2008 3:23 PM
Subject: Flexible XSD / XML generator



We have the requirement for a web service to respond XML in a flexible
format (flexible XSD) and i am looking to see if i can use internal CXF
classes for this. 

The web service exposes a complex and very large database read-only. For
every consumer a database view is generated, based on priviledges to see
certain columns and rows.  Then, every service consumer can define how
the data should be represented in XML. For example, the relation Order
-> OrderLine -> Book can be represented as one XML tree with all three
objects or as two XML trees with Order-> OrderLine  and one with Books.
See examples below.

This means that the XSD and XML is flexible and different per consumer.
Over a hundred consumers exist.

The XSD/WSDL should generated and XML produced without restarting or
programming the application. 

Any suggestions to how to solve this with CXF ?

JAXB is out-of-question (because XSD generation is at developtime),
which XML binding framework is best suited for this? 





Simple one XML tree:


<Order>
<OrderLine>
<Book id="100">
<Title>Hitchhikers Guide</Title>
</Book>
<Quantity>1</Quantity>
</OrderLine>
<OrderLine>
<Book id="200">
<Title>CXF Guide</Title>
</Book>
<Quantity>2</Quantity>
</OrderLine>
</Order>

Or as two XML trees like this:


<Order>
<OrderLine>
<BookId>100</BookId>
<Quantity>1</Quantity>
</OrderLine>
<OrderLine>
<BookId>200</BookId>
<Quantity>2</Quantity>
</OrderLine>
</Order>
<Books>
<Book id="100">
<Title>Hitchhikers Guide</Title>
</Book>
<Book id="200">
<Title>CXF Guide</Title>
</Book>
</Books>





Met vriendelijke groet,
Marcel Heemskerk
Software Architect Polis+ Webservices


----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland