Problems in parsing results of web service invocation - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Problems in parsing results of web service invocation

Hi everybody, I'm studying ws technology and have to write a service that parse an xml document and print its content (using Apache Tomcat and Axis2). The xml is like this:
[code]
<?xml version="1.0" encoding="UTF-8"?>


Navel
Arance







Tarocco
Arance







Limoni_di_Sorrento
Limoni






Clementine
Mandarini






Limoni_sfusi
Limoni






Mandarini
Mandarini






Arance_da_giardino
Arance






[/code]

I've wrote two beans for the "prodotto" and "confezione" elements and a class named ProdottoDB to deal with those data server side (I can post them if it can help).

After that I wrote a server class and a client class, and at that point the problem started to come out: when I launch the client this is the result:
[code]
ID: 1
Categoria: Arance
Nome: Navel
Exception in thread "main" java.lang.NullPointerException
at it.terramica.client.TerramicaClient.main(TerramicaClient.java:45)
[/code]

The client class:
[code]
public class TerramicaClient {

public static void main(String[] args) throws Exception {

BufferedReader console = new BufferedReader(new InputStreamReader(System.in));

System.out.println("Scegliere l'operazione da eseguire: ");
System.out.println("1 - Elenco prodotti: ");
System.out.println("2 - Ricerca prezzo: ");
int sel = Integer.parseInt(console.readLine());
//
//System.out.println("I prodotti non sono disponibili");

if (sel==1) {
ArrayList prods = elenca();
for (Prodotto p : prods) {
System.out.println("ID: " + p.getID());
System.out.println("Categoria: " + p.getCategoria());
System.out.println("Nome: " + p.getNome());

Confezione[] confs = p.getConfezione();
for (int i=0; i<confs.length; i++) {
System.out.println("Tipo confezione: " + confs[i].getTipo());
System.out.println("Peso confezione: " + confs[i].getPeso());
System.out.println("Prezzo confezione: " + confs[i].getPrezzo());
}
}
}

if (sel==2) {
System.out.println("ID?: ");
int id = Integer.parseInt(console.readLine());
System.out.println("Tipo?: ");
String tipo = console.readLine();

float res = prezzo(id, tipo);
if (res == -1)
System.out.print("ERRORE: l'articolo cercato non
Sign In or Register to comment.