Problemas com Axis

11 respostas
M

Pessoal,

após ler o tutorial sobre o Axis aqui no GUJ, fiz a instalação do TomCat, Axis, criei meu primeiro WebService, mas tive problemas na hora de rodar o client.

Meu WebService possui a seguinte assinatura:

Este é o meu client:

import java.rmi.RemoteException;

import javax.xml.rpc.ServiceException;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;

public class ClientWS {
    
    public static void main(String[] args) {
    	
        try {
			String endpoint = "http://localhost:8080/axis/EASports.jws";
			Service service = new Service();
			Call call = (Call) service.createCall();
			call.setTargetEndpointAddress(endpoint);
			call.setOperationName("testeWebService");
			String ret = (String) call.invoke(new Object[]{new String("marco")});
			System.out.println("Got result : " + ret);        	
        } catch (ServiceException se) {
        	System.out.println("ServiceException: "+se.getMessage());
        } catch (RemoteException re) {
			System.out.println("RemoteException: "+re.getMessage());
        } catch (Exception e) {
			System.out.println("Exception: "+e.getMessage());
        }
                
    }
}

E esta é a minha exception:

:frowning:

java.lang.ExceptionInInitializerError

at org.apache.axis.client.Service.getAxisClient(Service.java:143)

at org.apache.axis.client.Service.(Service.java:152)

at ClientWS.main(ClientWS.java:14)

Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.reflect.InvocationTargetException

at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:532)

at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:272)

at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:414)

at org.apache.axis.components.logger.LogFactory.getLog(LogFactory.java:76)

at org.apache.axis.handlers.BasicHandler.<clinit>(BasicHandler.java:81)

 3 more

Caused by: java.lang.reflect.InvocationTargetException

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)

at java.lang.reflect.Constructor.newInstance(Constructor.java:415)

at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:525)

 7 more

Caused by: java.lang.VerifyError: (class: org/apache/log4j/LogManager, method: <clinit> signature: ()V) Incompatible argument to function

at org.apache.log4j.Logger.getLogger(Logger.java:85)

at org.apache.commons.logging.impl.Log4JLogger.(Log4JLogger.java:102)

 12 more

Exception in thread main

Alguém se habilita?

PS: Todos os arquivos .jar de C:axis-1_1lib estão no claspath.

Atenciosamente,

11 Respostas

W

Você disse que leu o tutorial do axis agui no guj, onde está, não encontrei. Estou precisando invocar webservices feitos em delphi, vc sabe se é possível?

M

http://www.guj.com.br/servlet/guj?PARSE=true&MAMUTE_ACTION=br.com.guj.action.ListArticle&MAMUTE_TEMPLATE=ShowArticle&LIST_ARTICLE=single&ArticleId=32&PAGE=1

Acredito ser possível invocar WebServices feitos em qualquer linguagem, afinal, não é essa uma das vantagens do dito cujo?

W

espero que sim !!! :smiley:

M

Pessoal,

descobri que meu problema estava na ordem do ClassPath. O Log4J estava sendo importado do pacote errado e por isso estava gerando aquela exception.

Infelizmente estou recebendo uma outra mensagem de erro quando rodo o meu Client:

Exception&#58; No such operation 'testeWebService'
AxisFault
 faultCode&#58; Server.userException
 faultSubcode&#58; 
 faultString&#58; No such operation &amp;apos;testeWebService&amp;apos;
 faultActor&#58; 
 faultNode&#58; 
 faultDetail&#58; 
	&#123;http&#58;//xml.apache.org/axis/&#125;stackTrace&#58; AxisFault
 faultCode&#58; Server.userException
 faultSubcode&#58; 
 faultString&#58; No such operation &amp;amp;apos;testeWebService&amp;amp;apos;
 faultActor&#58; 
 faultNode&#58; 
 faultDetail&#58; 

No such operation 'testeWebService'
	at org.apache.axis.message.SOAPFaultBuilder.createFault&#40;SOAPFaultBuilder.java&#58;260&#41;
	at org.apache.axis.message.SOAPFaultBuilder.endElement&#40;SOAPFaultBuilder.java&#58;169&#41;
	at org.apache.axis.encoding.DeserializationContextImpl.endElement&#40;DeserializationContextImpl.java&#58;1015&#41;
	at weblogic.apache.xerces.parsers.AbstractSAXParser.endElement&#40;AbstractSAXParser.java&#58;585&#41;
	at weblogic.apache.xerces.impl.XMLNamespaceBinder.handleEndElement&#40;XMLNamespaceBinder.java&#58;898&#41;
	at weblogic.apache.xerces.impl.XMLNamespaceBinder.endElement&#40;XMLNamespaceBinder.java&#58;644&#41;
	at weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement&#40;XMLDocumentFragmentScannerImpl.java&#58;1008&#41;
	at weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch&#40;XMLDocumentFragmentScannerImpl.java&#58;1469&#41;
	at weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument&#40;XMLDocumentFragmentScannerImpl.java&#58;329&#41;
	at weblogic.apache.xerces.parsers.DTDConfiguration.parse&#40;DTDConfiguration.java&#58;525&#41;
	at weblogic.apache.xerces.parsers.DTDConfiguration.parse&#40;DTDConfiguration.java&#58;581&#41;
	at weblogic.apache.xerces.parsers.XMLParser.parse&#40;XMLParser.java&#58;152&#41;
	at weblogic.apache.xerces.parsers.AbstractSAXParser.parse&#40;AbstractSAXParser.java&#58;1175&#41;
	at weblogic.xml.jaxp.WebLogicXMLReader.parse&#40;WebLogicXMLReader.java&#58;135&#41;
	at weblogic.xml.jaxp.RegistryXMLReader.parse&#40;RegistryXMLReader.java&#58;138&#41;
	at javax.xml.parsers.SAXParser.parse&#40;SAXParser.java&#58;345&#41;
	at org.apache.axis.encoding.DeserializationContextImpl.parse&#40;DeserializationContextImpl.java&#58;242&#41;
	at org.apache.axis.SOAPPart.getAsSOAPEnvelope&#40;SOAPPart.java&#58;538&#41;
	at org.apache.axis.Message.getSOAPEnvelope&#40;Message.java&#58;376&#41;
	at org.apache.axis.client.Call.invokeEngine&#40;Call.java&#58;2583&#41;
	at org.apache.axis.client.Call.invoke&#40;Call.java&#58;2553&#41;
	at org.apache.axis.client.Call.invoke&#40;Call.java&#58;2248&#41;
	at org.apache.axis.client.Call.invoke&#40;Call.java&#58;2171&#41;
	at org.apache.axis.client.Call.invoke&#40;Call.java&#58;1691&#41;
	at ClientWS.main&#40;ClientWS.java&#58;14&#41;


No such operation 'testeWebService'
	at org.apache.axis.message.SOAPFaultBuilder.createFault&#40;SOAPFaultBuilder.java&#58;260&#41;
	at org.apache.axis.message.SOAPFaultBuilder.endElement&#40;SOAPFaultBuilder.java&#58;169&#41;
	at org.apache.axis.encoding.DeserializationContextImpl.endElement&#40;DeserializationContextImpl.java&#58;1015&#41;
	at weblogic.apache.xerces.parsers.AbstractSAXParser.endElement&#40;AbstractSAXParser.java&#58;585&#41;
	at weblogic.apache.xerces.impl.XMLNamespaceBinder.handleEndElement&#40;XMLNamespaceBinder.java&#58;898&#41;
	at weblogic.apache.xerces.impl.XMLNamespaceBinder.endElement&#40;XMLNamespaceBinder.java&#58;644&#41;
	at weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement&#40;XMLDocumentFragmentScannerImpl.java&#58;1008&#41;
	at weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch&#40;XMLDocumentFragmentScannerImpl.java&#58;1469&#41;
	at weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument&#40;XMLDocumentFragmentScannerImpl.java&#58;329&#41;
	at weblogic.apache.xerces.parsers.DTDConfiguration.parse&#40;DTDConfiguration.java&#58;525&#41;
	at weblogic.apache.xerces.parsers.DTDConfiguration.parse&#40;DTDConfiguration.java&#58;581&#41;
	at weblogic.apache.xerces.parsers.XMLParser.parse&#40;XMLParser.java&#58;152&#41;
	at weblogic.apache.xerces.parsers.AbstractSAXParser.parse&#40;AbstractSAXParser.java&#58;1175&#41;
	at weblogic.xml.jaxp.WebLogicXMLReader.parse&#40;WebLogicXMLReader.java&#58;135&#41;
	at weblogic.xml.jaxp.RegistryXMLReader.parse&#40;RegistryXMLReader.java&#58;138&#41;
	at javax.xml.parsers.SAXParser.parse&#40;SAXParser.java&#58;345&#41;
	at org.apache.axis.encoding.DeserializationContextImpl.parse&#40;DeserializationContextImpl.java&#58;242&#41;
	at org.apache.axis.SOAPPart.getAsSOAPEnvelope&#40;SOAPPart.java&#58;538&#41;
	at org.apache.axis.Message.getSOAPEnvelope&#40;Message.java&#58;376&#41;
	at org.apache.axis.client.Call.invokeEngine&#40;Call.java&#58;2583&#41;
	at org.apache.axis.client.Call.invoke&#40;Call.java&#58;2553&#41;
	at org.apache.axis.client.Call.invoke&#40;Call.java&#58;2248&#41;
	at org.apache.axis.client.Call.invoke&#40;Call.java&#58;2171&#41;
	at org.apache.axis.client.Call.invoke&#40;Call.java&#58;1691&#41;
	at ClientWS.main&#40;ClientWS.java&#58;14&#41;

A assinatura do WebService está correta:

public String testeWebService&#40;&#41;;

E se eu chamo a URL http://localhost:8080/axis/EASports.jws?wsdl, recebo a seguinte resposta:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt; 
- &lt;wsdl&#58;definitions targetNamespace=&quot;http&#58;//localhost&#58;8080/axis/EASports.jws&quot; xmlns=&quot;http&#58;//schemas.xmlsoap.org/wsdl/&quot; xmlns&#58;apachesoap=&quot;http&#58;//xml.apache.org/xml-soap&quot; xmlns&#58;impl=&quot;http&#58;//localhost&#58;8080/axis/EASports.jws&quot; xmlns&#58;intf=&quot;http&#58;//localhost&#58;8080/axis/EASports.jws&quot; xmlns&#58;soapenc=&quot;http&#58;//schemas.xmlsoap.org/soap/encoding/&quot; xmlns&#58;wsdl=&quot;http&#58;//schemas.xmlsoap.org/wsdl/&quot; xmlns&#58;wsdlsoap=&quot;http&#58;//schemas.xmlsoap.org/wsdl/soap/&quot; xmlns&#58;xsd=&quot;http&#58;//www.w3.org/2001/XMLSchema&quot;&gt;
- &lt;wsdl&#58;message name=&quot;testeWebServiceResponse&quot;&gt;
  &lt;wsdl&#58;part name=&quot;testeWebServiceReturn&quot; type=&quot;xsd&#58;string&quot; /&gt; 
  &lt;/wsdl&#58;message&gt;
  &lt;wsdl&#58;message name=&quot;testeWebServiceRequest&quot; /&gt; 
- &lt;wsdl&#58;portType name=&quot;EASports&quot;&gt;
- &lt;wsdl&#58;operation name=&quot;testeWebService&quot;&gt;
  &lt;wsdl&#58;input message=&quot;impl&#58;testeWebServiceRequest&quot; name=&quot;testeWebServiceRequest&quot; /&gt; 
  &lt;wsdl&#58;output message=&quot;impl&#58;testeWebServiceResponse&quot; name=&quot;testeWebServiceResponse&quot; /&gt; 
  &lt;/wsdl&#58;operation&gt;
  &lt;/wsdl&#58;portType&gt;
- &lt;wsdl&#58;binding name=&quot;EASportsSoapBinding&quot; type=&quot;impl&#58;EASports&quot;&gt;
  &lt;wsdlsoap&#58;binding style=&quot;rpc&quot; transport=&quot;http&#58;//schemas.xmlsoap.org/soap/http&quot; /&gt; 
- &lt;wsdl&#58;operation name=&quot;testeWebService&quot;&gt;
  &lt;wsdlsoap&#58;operation soapAction=&quot;&quot; /&gt; 
- &lt;wsdl&#58;input name=&quot;testeWebServiceRequest&quot;&gt;
  &lt;wsdlsoap&#58;body encodingStyle=&quot;http&#58;//schemas.xmlsoap.org/soap/encoding/&quot; namespace=&quot;http&#58;//DefaultNamespace&quot; use=&quot;encoded&quot; /&gt; 
  &lt;/wsdl&#58;input&gt;
- &lt;wsdl&#58;output name=&quot;testeWebServiceResponse&quot;&gt;
  &lt;wsdlsoap&#58;body encodingStyle=&quot;http&#58;//schemas.xmlsoap.org/soap/encoding/&quot; namespace=&quot;http&#58;//localhost&#58;8080/axis/EASports.jws&quot; use=&quot;encoded&quot; /&gt; 
  &lt;/wsdl&#58;output&gt;
  &lt;/wsdl&#58;operation&gt;
  &lt;/wsdl&#58;binding&gt;
- &lt;wsdl&#58;service name=&quot;EASportsService&quot;&gt;
- &lt;wsdl&#58;port binding=&quot;impl&#58;EASportsSoapBinding&quot; name=&quot;EASports&quot;&gt;
  &lt;wsdlsoap&#58;address location=&quot;http&#58;//localhost&#58;8080/axis/EASports.jws&quot; /&gt; 
  &lt;/wsdl&#58;port&gt;
  &lt;/wsdl&#58;service&gt;
  &lt;/wsdl&#58;definitions&gt;

O que estou fazendo de errado?

Obrigado,

W

Fui tentar compilar o arquivo FibClient do tutorial e obtive os seguintes erros:

--------------------Custom Tool: javac--------------------

FibClient.java:6: cannot resolve symbol

symbol  : class Service

location: class FibClient

Service service = new Service();

^

FibClient.java:6: cannot resolve symbol

symbol  : class Service

location: class FibClient

Service service = new Service();

^

FibClient.java:7: cannot resolve symbol

symbol  : class Call

location: class FibClient

Call call = (Call) service.createCall();

^

FibClient.java:7: cannot resolve symbol

symbol  : class Call

location: class FibClient

Call call = (Call) service.createCall();

^

4 errors

Process completed.

Já coloquei todos os .jar que tem dentro da instalação do axis no meu classpath. Você sabe o que pode estar faltando?

M

Provavelmente está faltando os imports:

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;

W

Exatamente…coloquei-os e funcionou !!! Valeu
E vc conseguiu resolver seu problema?

M

“wender”:
Exatamente…coloquei-os e funcionou !!! Valeu
E vc conseguiu resolver seu problema?

Infelizmente meu client ainda não está funcionando.

Você conseguiu rodar o exemplo completo? Seu client funcionou?

Entrei para a lista de usuários do Axis, postei uma mensagem lá, mas até agora fui ignorado solenemente, ou como gosta de dizer um amigo meu: defecaram no meu crânio! :frowning:

W

consegui chamar o exemplo do Fibonacci mas o do Google não

M

Então fiz alguma bobagem no meu Client, vou tentar de novo com um exemplo igual ao do artigo!

Quanto ao Google, você tem o número de licença para fazer a chamada ao WebService?

M

Então fiz alguma bobagem no meu Client, vou tentar de novo com um exemplo igual ao do artigo!

Realmente havia um erro no Client:

String ret = &#40;String&#41; call.invoke&#40;new Object&#91;&#93;&#123;new String&#40;&#41;&#125;&#41;;

Enquanto que a assinatura do meu WebService era:

Bastou alterar a assinatura do meu WebService e tudo funcionou:

Criado 2 de março de 2004
Ultima resposta 4 de mar. de 2004
Respostas 11
Participantes 2