Finalmente consegui gerar um webservice com AXIS apartir do Eclipse!
Agora não consigo fazer o cliente funcionar…
http://localhost:8080/AxisExemplo/wsdl/PegaIdade.wsdl
<?xml version="1.0" encoding="UTF-8" ?>
- <wsdl:definitions targetNamespace="http://dao" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://dao" xmlns:intf="http://dao" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <!--
WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)
-->
- <wsdl:types>
- <schema elementFormDefault="qualified" targetNamespace="http://dao" xmlns="http://www.w3.org/2001/XMLSchema">
- <element name="getIdade">
- <complexType>
- <sequence>
<element name="i" type="xsd:int" />
</sequence>
</complexType>
</element>
- <element name="getIdadeResponse">
- <complexType>
- <sequence>
<element name="getIdadeReturn" type="xsd:int" />
</sequence>
</complexType>
</element>
</schema>
</wsdl:types>
- <wsdl:message name="getIdadeResponse">
<wsdl:part element="impl:getIdadeResponse" name="parameters" />
</wsdl:message>
- <wsdl:message name="getIdadeRequest">
<wsdl:part element="impl:getIdade" name="parameters" />
</wsdl:message>
- <wsdl:portType name="PegaIdade">
- <wsdl:operation name="getIdade">
<wsdl:input message="impl:getIdadeRequest" name="getIdadeRequest" />
<wsdl:output message="impl:getIdadeResponse" name="getIdadeResponse" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="PegaIdadeSoapBinding" type="impl:PegaIdade">
<wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="getIdade">
<wsdlsoap:operation soapAction="" />
- <wsdl:input name="getIdadeRequest">
<wsdlsoap:body use="literal" />
</wsdl:input>
- <wsdl:output name="getIdadeResponse">
<wsdlsoap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="PegaIdadeService">
- <wsdl:port binding="impl:PegaIdadeSoapBinding" name="PegaIdade">
<wsdlsoap:address location="http://localhost:8080/AxisExemplo/services/PegaIdade" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Cliente:
[code]
import org.apache.axis.MessageContext;
import org.apache.axis.client.Service;
import org.apache.axis.client.Call;
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/AxisExemplo/wsdl/PegaIdade.wsdl”;
// Criando e configurando o serviço
Call call = (Call) new Service().createCall();
// Configurando o endereço.
call.setTargetEndpointAddress(local);
// Marcando o método a ser chamado.
call.setOperationName("getIdade");
// Parâmetros da função soma.
Object[] param = new Object[]{1};
// Retorno da Função
Integer ret = (Integer)call.invoke(param);
// Imprime o resultado: ret = 2 + 4.
System.out.println("Resultado da soma : " + ret);
}
}[/code]
Erro
- Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled.
Exception in thread "main" AxisFault
faultCode: {http://xml.apache.org/axis/}HTTP
faultSubcode:
faultString: (404)/AxisExemplo/wsdl/PegaIdade.wsdl
faultActor:
faultNode:
faultDetail:
{}:return code: 404
<html><head><title>Apache Tomcat/6.0.16 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 404 - /AxisExemplo/wsdl/PegaIdade.wsdl</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>/AxisExemplo/wsdl/PegaIdade.wsdl</u></p><p><b>description</b> <u>The requested resource (/AxisExemplo/wsdl/PegaIdade.wsdl) is not available.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/6.0.16</h3></body></html>
{http://xml.apache.org/axis/}HttpErrorCode:404
(404)/AxisExemplo/wsdl/PegaIdade.wsdl
at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:744)
at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165)
at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
at org.apache.axis.client.Call.invoke(Call.java:2767)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at imasters.Cliente.main(Cliente.java:21)