I'm trying to develop a form generator in java, in which users will be able to write a wsdl url and get the list of the operations supported by the web service in a ComboBox. When the user selects one of the items in ComboBox then he will see form fields generated using the wsdl url.
I'm a newbie in web service technologies, after searching about web service parsers on the net I decided to use axis library. But I really do not know which part of the wsdl document should I parse
I'm not trying to create java classes of the web service, I have to generate form fields for any wsdl url.
For instance here is a web service which provides 9 operations
http://services.aonaware.com/DictService/DictService.asmx
and the wsdl file is here:
http://services.aonaware.com/DictService/DictService.asmx?WSDL
I need to know which parts of wsdl file should be parsed, any help would be appreciated.
To get started with WSDL and understand how such a document is structured, you should maybe have a look at some article like Understanding WSDL or the WSDL Tutorial or any other beginner resource that you'll find on Google.
Now, to answer your question in a simplified way, you'll have to start with the portType
element that contains:
An abstract set of operations supported by one or more endpoints (commonly known as an interface); operations are defined by an exchange of messages
For example, in your case:
<wsdl:operation name="DictionaryList">
<wsdl:documentation>Returns a list of available dictionaries</wsdl:documentation>
<wsdl:input message="tns:DictionaryListSoapIn"/>
<wsdl:output message="tns:DictionaryListSoapOut"/>
</wsdl:operation>
And, for each operation, you'll need to parse the input and output messages, a message
being:
A definition of an abstract message that may consist of multiple parts, each part may be of a different type.
Here, for example the input message of the previous operation is:
<wsdl:message name="DictionaryListSoapIn">
<wsdl:part name="parameters" element="tns:DictionaryList"/>
</wsdl:message>
Then, to understand the content of the message, have a look at the types
:
A container for abstract type definitions defined using XML Schema
Here, the DictionaryList
element is defined as an empty compleType:
<s:element name="DictionaryList">
<s:complexType/>
</s:element>
As I said, this is really a very simplified answer as WSDL can't be summarized in four paragraphs and, to be honest, what you are going to do is really not a trivial task. Let me rephrase this: there will be blood! So, even if these few lines may help you (a very little) to get started, I'd definitely not start such a project from scratch but rather use an existing library or tool (like Xydra or Eclipse XML Forms Generator or ...) that would allow to not reinvent the wheel.
By the way, I noticed that you have decided to use Axis and that you don't want to generate the Java classes but I'd warmly recommend to not use Axis anyway. Actually, I'd use JAX-WS RI wich is bundled in Java 6 and is a much easier API. Just in case, to generate the Java classes, just execute:
$ mkdir generated
$ wsimport -d generated http://services.aonaware.com/DictService/DictService.asmx?WSDL
here is a good tutorial about "Reading a wsdl file" by Thomas Bayer http://www.predic8.com/wsdl-reading.htm
This is not a trivial project, and you may find that a library that already does this would be your best approach, but places to start would be mapping attributes to HTML FORM components, and the Min/Max Occues to JavaScript events.
It would likely be a lot easier to write your FORM from your understanding of the WSDL. As for something that could help, you could use something like
http://www.soapui.org/
Or for something web based (which I just tested with your WSDL and it works) you can try
http://www.soapclient.com/soaptest.html
I know that these two links might be totally off base for what you are trying to accomplish though, so good luck in your effort to tackle this challenge :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With