Automatically extracting inline XSD from WSDL into XSD file(s)
- by Steven Geens
I am using a third party Web Service whose definition and implementation are beyond my control.
This web service will change in the future.
The Web Service should be used to generate an XML file which contains some of the same data (represented by the same XSD types) as the Web Service plus some extra information generated by the program.
My approach:
create my own XSD referring to the XSD definitions of the WSDL of the called web service (This XSD also includes XSD types for the extra information obviously.)
use a Java XML databinding framework (like ADB or JiXB) to generate the databinding classes from my own XSD file from step 1
use a Java SOAP framework (like Axis2 or CXF) with the same databinding framework to generate the databinding classes from the WSDL (This would enable me to use the objects retrieved by the web service directly in the generation of the XML.)
The XSD types I am going to use in my own XSD file, but are defined in the WSDL, are subject to change. Whenever they change, I would like to automatically process the XSD and WSDL databinding again. (If the change is significant enough, this might trigger some development effort.(But usually not.))
My problem:
In step 1 I need an XSD referring to the same types as used by the Web Service.
The WSDL is referring to another WSDL, which is referring to another WSDL etc. Eventually there is an WSDL with the needed inline XSD types. As far as I know there is no way to directly reference the inline XSD types of a WSDL from an XSD.
The approach I would think most viable, is to include an extra step in the automatic processing (before the databinding) that extracts the inline XSD from the WSDL into other XSD file(s). These other XSD file(s) can then be referred to by my own XSD file.
Things I'd like to avoid:
Manually copy pasting the inline XSD into an XSD file (I am looking for an automatic process.)
Any manual steps.(Like the determining the WSDL that contains the inline types manually.(The location of that WSDL does change as well.))
Using xsd:any in my own XSD. I would like my own XSD file to be correct.
Using a non-Java technology(like .NET)
Huge amounts of implementation (but hints on how you would implement such an extraction are welcome anyway)
PS: I found some similar questions, but they all had responses like: WTH would you want to do that? That is the reason for my rather large background story.