<?xml version="1.0" encoding="UTF-8" ?>
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <soapenv:Body>
- <soapenv:Fault>
<faultcode>soapenv:Server.generalException</faultcode>
<faultstring>Tried to invoke method public int Servico.soma(int,int) with arguments java.lang.String,java.lang.String. The arguments do not match the signature.; nested exception is: java.lang.IllegalArgumentException: argument type mismatch</faultstring>
- <detail>
<ns1:hostname xmlns:ns1="http://xml.apache.org/axis/">SPTEC46</ns1:hostname>
</detail>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>
a) O autor do artigo atende no outro fórum (javafree.org)
b) Acho que a versão do Axis (JWS) que ele usou faz uma conversão automática de String para int que a sua versão não faz. É que a “fault string” diz que não achou um método soma (String, String).
Seria mais uma vez 5 estrelas thingol, uma leve alterada no arquivo .jws
public class Servico {
public int soma(String valor1, String valor2) {
return Integer.parseInt(valor1) + Integer.parseInt(valor2);
}
}
Agora outra dúvida, executando a classe do tutorial, me causa o seguinte erro:
//classe
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
public class Cliente {
public static void main(String[] args) throws Exception {
// Endereço, local onde encontra-se o Web Service
String local = "http://localhost:8080/axis/Servico.jws";
// Criando e configurando o serviço
Call call = (Call) new Service().getCall();
// Configurando o endereço.
call.setTargetEndpointAddress(local);
// Marcando o método a ser chamado.
call.setOperationName("soma");
// Parâmetros da função soma.
Object[] param = new Object[] { new Integer(2), new Integer(4) };
// Retorno da Função
Integer ret = (Integer) call.invoke(param);
// Imprime o resultado: ret = 2 + 4.
System.out.println("Resultado da soma : " + ret);
}
}
Erro:
- Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled.
Exception in thread "main" java.lang.NullPointerException
at br.com.wittel.ws.Cliente.main(Cliente.java:18)
Onde devo adicionar os jars activation.jar e mail.jar que possuem essas classes?
Estudar qualquer versão do Axis anterior ao Axis 2 1.1 é gastar massa cinzenta com coisa obsoleta.
[]s
Luca[/quote]
Olá Luca, gostaria de ter participado da sua palestra no CJ, essas conversões já são feitas automaticamente nessa versão e qual seria a url do download?