Reputation: 2547
I ran wsimport
on this WSDL
http://ws.dati.comune.milano.it/opendata/wsopendata.asmx?WSDL
and generated the client-side JAX-WS classes.
Now i want to use getOpenWifi
using this snippet :
String message = " ";
WSOpenData wsopendata = new WSOpenData();
GetOpenWifiResult result = wsopendata.getWSOpenDataSoap().getOpenWifi(" ");
List<Object> list = result.getContent();
for (Iterator<Object> iterator = list.iterator(); iterator.hasNext();) {
message += iterator.next().toString() + " ";
}
i'm obtaining message
as
[NewDataSet: null]
i think i'm doing something wrong, How can i retrieve the right dataset?
Upvotes: 1
Views: 638
Reputation: 976
When I call it with SoapUI I get something like
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<getOpenWifiResponse xmlns="http://comune.milano.it/">
<getOpenWifiResult>
<NewDataSet xmlns="">
<Table>
<ID>3</ID>
<Sito>Arco Della Pace</Sito>
<Zona>1</Zona>
<Attiva>1</Attiva>
<Codice>A0044</Codice>
<Coordinate>9.172460,45.475670,0.000000</Coordinate>
</Table>
<Table>
<ID>4</ID>
<Sito>Bastioni di Porta Nuova 23</Sito>
<Zona>1</Zona>
<Attiva>1</Attiva>
<Codice>E0725</Codice>
<Coordinate>9.192273,45.478577,0.000000</Coordinate>
</Table>
I think the "NewDataSet"-Object will have subobjects "table". Check the generated artefacts (which I don´t have)
€dit: Try that
import it.milano.comune.GetOpenWifiResponse.GetOpenWifiResult;
import it.milano.comune.WSOpenData;
import java.net.URL;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class Test {
/**
* @param args
*/
public static void main(String[] args) throws Exception {
WSOpenData ws = new WSOpenData(new URL("http://ws.dati.comune.milano.it/opendata/wsopendata.asmx?WSDL"));
GetOpenWifiResult rw = ws.getWSOpenDataSoap().getOpenWifi(" ");
for (Object o : rw.getContent()) {
System.out.println(o.getClass().getName());
Element e = (Element) o;
NodeList c = e.getChildNodes();
System.out.println(c);
for (int i = 0; i < c.getLength(); i++) {
Node table = c.item(i);
System.out.println("tab");
for (int i2 = 0; i2 < table.getChildNodes().getLength(); i2++) {
Node property = table.getChildNodes().item(i2);
System.out.println("\tp: " + property);
}
}
}
long x = 1;
}
}
It gave me
com.sun.org.apache.xerces.internal.dom.ElementNSImpl
[NewDataSet: null]
tab
p: [ID: null]
p: [Sito: null]
p: [Zona: null]
p: [Attiva: null]
p: [Codice: null]
p: [Coordinate: null]
tab
p: [ID: null]
p: [Sito: null]
p: [Zona: null]
p: [Attiva: null]
p: [Codice: null]
p: [Coordinate: null]
tab
p: [ID: null]
p: [Sito: null]
p: [Zona: null]
p: [Attiva: null]
p: [Codice: null]
p: [Coordinate: null]
tab
p: [ID: null]
p: [Sito: null]
p: [Zona: null]
p: [Attiva: null]
p: [Codice: null]
p: [Coordinate: null]
[...]
I´m sure if you experiment a bit you´ll be able to solve it
Upvotes: 2