I don't like template languages like Velocity either.
So I have decided to generate my WSDL in Grovvy.
I have installed the Eclipse Plugin:
http://dist.springsource.org/release/GRECLIPSE/e3.5/
or
http://dist.springsource.org/release/GRECLIPSE/e3.6/
Here a good example of how to parse XML with Groovy:
http://groovy.codehaus.org/Reading+XML+using+Groovy%27s+XmlParser
The XML defining the service is:
GeoServicePS 1 ../XSD/GEO_OSB_EJBSchema.xsd getCitiesByLikeCityName getLocationsByName getLocationsByLocationIds
First create a Groovy Project, then a Groovy class - this is only a POC on how to parse XML:
class WSDLGenerator {
static main(args) {
File file = new File("resources/geowsdl.xml");
def records = new XmlParser().parseText(file.getText());
def servicename = records.servicename.text();
def version = records.version.text();
def schemalocation = records.schemalocation.text();
def operations = records.operations;
for (operation in operations.operation) {
println operation.text();
}
}
}
It's as simple as that! In Java it would have taken me 5 times more code!
I will never edit manually a WSDL again, all you need is a XSD with your domain model, and you can generate the blessed WSDL by script.
No comments:
Post a Comment