I'm trying to consume the Post Office Web Service - Tracking. In net Benas I imported the WSDL into new-> client for Webservice. The problem is that the WebService is returning the empty list, I can not understand.
public static void main(String[] args) {
Sroxml result = buscaEventos("ECT", "SRO", "L", "T", "101", "OC013972795BR");
System.out.println("qtd "+result.getQtd());
System.out.println("Objeto "+result.getObjeto());
System.out.println(result.getObjeto().get(0).getNumero());
System.out.println(result.getObjeto().get(0).getEvento().get(0).getDescricao());
}
private static Sroxml buscaEventos(java.lang.String usuario, java.lang.String senha, java.lang.String tipo, java.lang.String resultado, java.lang.String lingua, java.lang.String objetos) {
br.com.correios.webservice.resource.Rastro service = new br.com.correios.webservice.resource.Rastro();
br.com.correios.webservice.resource.Service port = service.getServicePort();
return port.buscaEventos(usuario, senha, tipo, resultado, lingua, objetos);
}
}
And you're giving this error:
run: qtd 1
Object []
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.rangeCheck (ArrayList.java:653) at java.util.ArrayList.get (ArrayList.java:429) at javaapplication3.JavaApplication3.main (JavaApplication3.java:11) C: \ Users \ lorena \ Documents \ NetBeansProjects \ JavaApplication3 \ nbproject \ build-impl.xml: 1041: The following error occurred while executing this line: C: \ Users \ lorena \ Documents \ NetBeansProjects \ JavaApplication3 \ nbproject \ build-impl.xml: 806: Java returned: 1 CONSTRUCTION FAIL (total time: 5 seconds)