Olá,
quando incluo o metodo que volta uma String usando XSTREAM me da o erro abaixo
There is a Web Service here
Click to see the WSDL
Outra duvida essa é forma usual de gerar um WebService quando se tem uma lista gerar um XML e retornar como String ou definir como retorno um List e retorna uma lista qual é a melhor forma ???
Se alguém puder me ajudar agradeceria…
abs
AXIS error
Sorry, something seems to have gone wrong... here are the details:
Fault - Error while compiling: C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\axis\WEB-INF\jwsClasses\Servico.java
AxisFault
faultCode: {http://xml.apache.org/axis/}Server.compileError
faultSubcode:
faultString: Error while compiling: C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\axis\WEB-INF\jwsClasses\Servico.java
faultActor:
faultNode:
faultDetail:
{}Errors:Error compiling C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\axis\WEB-INF\jwsClasses\Servico.java:
Line 15, column -1: cannot find symbol
Line 15, column -1: cannot find symbol
Line 16, column -1: cannot find symbol
Line 16, column -1: cannot find symbol
Line 24, column -1: cannot find symbol
Line 24, column -1: cannot find symbol
Line 31, column -1: cannot find symbol
Line 37, column -1: cannot find symbol
Line 0, column 0:
8 errors
import java.util.ArrayList;
import java.util.List;
import com.thoughtworks.xstream.XStream;
public class Servico {
public int soma(int valor1, int valor2) {
return valor1 + valor2;
}
public String getClientes(int codigo){
Cliente[] clientes = new Cliente[3];
List<Cliente> lista = new ArrayList<Cliente>();
String contatosEmXML = null;
// Configurando XStream
XStream xstream = new XStream();
if (codigo>0){
Cliente cli = new Cliente();
cli.setCodigo(10);
cli.setNome("Jose da Silva");
cli.setEndereco("Rua 1");
clientes[0]=cli;
lista.add(cli);
cli = new Cliente();
cli.setCodigo(20);
cli.setNome("Mario da Silva");
cli.setEndereco("Rua 2");
clientes[1]=cli;
lista.add(cli);
cli = new Cliente();
cli.setCodigo(30);
cli.setNome("Um da Silva");
cli.setEndereco("Rua 3");
clientes[2]=cli;
lista.add(cli);
// Passando os dados de Objetos Java para XML
contatosEmXML = xstream.toXML(lista);
System.out.print(contatosEmXML);
}
return contatosEmXML;
}
public static void main (String[] args){
Servico ss = new Servico();
ss.getClientes(1);
}
}