Monday, July 17, 2006

WSDL Validation with wsdl4j

Imagine a set up where a team A provides Web Services to Team B. The service team A uses a "contract first" SOA approach, so they hand-write WSDL (more on that another time) and generate Java from it (not the other way around). Team A then implements these services using XFire as their SOAP stack. Now Team B takes these WSDL documents and generates client code from it, using Axis1.

Now WSDL being a standard format, this is a painless no-brainer, right? Right. Turns out Axis1 has a small but annoying bug which leads to it generating invalid Java code, which does not compile, from technically perfectly valid WSDL (if the 'name' of a <wsdl:message> used for a Fault has the same name as the actual <xsd:element> referenced by the <wsdl:part> in the <wsdl:message>). Easy to slightly adapt the original WSDL - once you have figured this out.

Of course, being "agile", I don't want this problem to come back haunting the team every so often, and thought about how to enforce/test the hand-written WSDL, which is perfectly valid technically, for this specific condition, during the automated build.

Turns out that thanks to JSR 110 & wsdl4j, this is pretty painless! The little WSDLValidationTask for ant (download WSDLValidationTask.java source) that I ended up hacking together is used like this:

<taskdef name="wsdl-validation" classname="wsdlvalidation.wsdl.WSDLValidationTask" />
<wsdl-validation>
<wsdl dir="wsdldir" includes="my.wsdl" />
</wsdl-validation>

1 Comments:

Anonymous Anonymous said...

Nice article

12 November, 2009 14:08  

Post a Comment

<< Home