This week's book giveaway is in the Other Open Source APIs forum. We're giving away four copies of Storm Applied and have Sean Allen, Peter Pathirana & Matthew Jankowski on-line! See this thread for details.
I had to generate webservices from WSDL and I used Eclipse to do so (New -> Webservices -> Top-bottom, etc)
So far the generated code is good except for one thing: the arrays are not working as expected because the array tag is the same as the one given for the elements in the array.
This example will show you clearly what's going on:
A part of my WSDL where I have an array called "Transmisiones" whose elements should be tagged as "TransmisionDatos":
What I expected it to generate (an array Transmisiones with N embedded TransmisionDatos elements):
What it actually generates (response received using SoapUI for testing):
As you can see, surprisingly the tag for the array Transmisiones is the same as for the elements of the array.
I've been playing with the WSDL for days but I couldn't get the tool to generate code that uses a different tag for the array and its elements.
This code is useless because the program that is calling my WS expects a response with correctly build arrays.
Do I have to change the WSDL or any other thing? I'm going crazy over this, any help will be greatly appreciated . Cheers.
Joined: Sep 20, 2011
Maybe I didn't make it clear enough.
I just want to know how to set up an array in WSDL so that the code generated by WSDL2Java names the array container (ListOfThings) different than the elements it contains (Thing)
Arrays in Webservices, it can't be so complicated, somebody must have hit this issue before.
1. Basically, I used Eclipse to create a xml schema file NewXMLSchema.xsd
2. I generate an example of xml file using that NewXMLSchema.xml
I found the error is
<xs:element ref="ns1atosEspecificos" minOccurs="0"/>
Edited: to be specific
I remove minOccurs="0" and it worked because minOccurs="0" means Transmisiones should have no children TransmisionDatos
Joined: Sep 20, 2011
Thank you both for your answers.
I had to leave this problem with a temporary solution (removing maxOccurs I got a simpler WSDL that generated an array of 1 element, or just a nested element inside the other) because I had a lot of other urgent stuff to do but I really appreciate your time and dedication.
However, I just changed the WDSL to remove minOccurs and still keep getting the same name for the array and the elements of the array:
The WSDL was provided by the client and I guess that the XML generated from it should be fine so I'm wondering if this is all a problem related to the tool I use to generate the code.
Maybe I should give a try to wsimport as Ivan Krizsan suggested, if I get back to the issue I'll keep you posted.