modular wsdl problem in axis2

Fri, Apr 6, 2007

I’ve been writing some web services for the ASK project, which involve putting the CollectionManager interface online as a web service. As it’s rather large I thought I’d split up the WSDL into modular parts. Why create WSDL manually and not generate it from the implementation class? Well, the interface has method overrides in it, which aren’t allowed in WSDL2.0, so to keep on the right side of the standards, I modified the interface to remove the overrides and created the WSDL by hand. I could have just coded up a dummy impl class for the modified interface but the trend these days is to use WSDL as your API and to design from the ground up using WSDL. Plus it would be good to keep my WSDL skills sharp.

The following diagram shows what I did. There’s a root WSDL, which just defines the service name and location. It then imports the root XML schema that defines the WSDL message types. That in turn imports the domain XML schema for the ASK web service data objects. The root WSDL also imports the bindings from another WSDL file. The bindings file then imports the portTypes WSDL file, which in turn imports the messages WSDL file. So if I want to, say, offer the CollectionManager service over another type of protocol, I just have to import a different bindings file. If I want to change method signatures in the service, I just modify the messages types XML schema file.

Modular WSDL. Click on image for bigger size

When I ran it all through Axis2 wsdl2java, it blew up with the error:

org.apache.axis2.AxisFault: First Element must contain the local name, Envelope

So I put the whole lot into one WSDL file and it worked. I then went back to the modular WSDL and changed the way the XML schema were imported. The root WSDL imported both XML schema files, for the WSDL messages types and the ASK domain types. However, it transpired that the ASK domain types were not visible to the WSDL messages types and that’s what was causing the problem.

So I refactored by removing the ASK domain import from the root WSDL and importing it from the WSDL messages types schema instead.

Now it all works.

comments powered by Disqus