Web service does not access my classes

Asked

Viewed 223 times

0

I am building a web service, previously it was already working normally but the scripts were all in one package, so I decided to organize in different packages my scripts

inserir a descrição da imagem aqui

however now my web service does not access classes that are in a package other than web service codes, and I get this message in Soapui

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <soapenv:Fault>
         <faultcode>soapenv:Server</faultcode>
         <faultstring>br.com.sata.Classes.Usuario</faultstring>
         <detail/>
      </soapenv:Fault>
   </soapenv:Body>
</soapenv:Envelope>

JAVA code

package br.com.sata.WebService;

import java.sql.SQLException;

import br.com.sata.Classes.Usuario;
import br.com.sata.Crud.Crud_Usuario;
import br.com.sata.Validacao.ValidaUsuario;

public class WS_Usuario 
{
    public String inserirUsuario(Usuario usuario) throws SQLException
    {
        String message = ValidaUsuario.testaCampos(usuario);
        if(message != "OK")
        {
            return message;
        }
        return Crud_Usuario.inserirUsuario(usuario);
    }
}

XML of the Web Service

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ns="http://WebService.sata.com.br" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ax219="http://Classes.sata.com.br/xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ax217="http://sql.java/xsd" targetNamespace="http://WebService.sata.com.br">
<wsdl:documentation>Please Type your service description here</wsdl:documentation>
<wsdl:types>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://Classes.sata.com.br/xsd">
<xs:complexType name="Infos">
<xs:sequence>
<xs:element minOccurs="0" name="bairro" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="canc" type="xs:int"/>
<xs:element minOccurs="0" name="celular" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="complemento" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="conc" type="xs:int"/>
<xs:element minOccurs="0" name="cp" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="email" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="id" type="xs:int"/>
<xs:element minOccurs="0" name="idCidadeFK" type="xs:int"/>
<xs:element minOccurs="0" name="nome" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="numero" type="xs:int"/>
<xs:element minOccurs="0" name="reputacao" type="xs:double"/>
<xs:element minOccurs="0" name="rua" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="telefone" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="Usuario">
<xs:complexContent>
<xs:extension base="ax219:Infos">
<xs:sequence>
<xs:element minOccurs="0" name="login" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="senha" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://sql.java/xsd">
<xs:complexType name="SQLException">
<xs:sequence>
<xs:element minOccurs="0" name="SQLState" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="errorCode" type="xs:int"/>
<xs:element minOccurs="0" name="nextException" nillable="true" type="ax217:SQLException"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
<xs:schema xmlns:ax220="http://Classes.sata.com.br/xsd" xmlns:ax218="http://sql.java/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://WebService.sata.com.br">
<xs:import namespace="http://sql.java/xsd"/>
<xs:import namespace="http://Classes.sata.com.br/xsd"/>
<xs:element name="WS_UsuarioSQLException">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="SQLException" nillable="true" type="ax218:SQLException"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="inserirUsuario">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="usuario" nillable="true" type="ax220:Usuario"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="inserirUsuarioResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="excluirUsuario">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="login" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="senha" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="excluirUsuarioResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="atualizarUsuario">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="usuario" nillable="true" type="ax220:Usuario"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="atualizarUsuarioResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="excluirUsuarioRequest">
<wsdl:part name="parameters" element="ns:excluirUsuario"/>
</wsdl:message>
<wsdl:message name="excluirUsuarioResponse">
<wsdl:part name="parameters" element="ns:excluirUsuarioResponse"/>
</wsdl:message>
<wsdl:message name="WS_UsuarioSQLException">
<wsdl:part name="parameters" element="ns:WS_UsuarioSQLException"/>
</wsdl:message>
<wsdl:message name="atualizarUsuarioRequest">
<wsdl:part name="parameters" element="ns:atualizarUsuario"/>
</wsdl:message>
<wsdl:message name="atualizarUsuarioResponse">
<wsdl:part name="parameters" element="ns:atualizarUsuarioResponse"/>
</wsdl:message>
<wsdl:message name="inserirUsuarioRequest">
<wsdl:part name="parameters" element="ns:inserirUsuario"/>
</wsdl:message>
<wsdl:message name="inserirUsuarioResponse">
<wsdl:part name="parameters" element="ns:inserirUsuarioResponse"/>
</wsdl:message>
<wsdl:portType name="WS_UsuarioPortType">
<wsdl:operation name="excluirUsuario">
<wsdl:input message="ns:excluirUsuarioRequest" wsaw:Action="urn:excluirUsuario"/>
<wsdl:output message="ns:excluirUsuarioResponse" wsaw:Action="urn:excluirUsuarioResponse"/>
<wsdl:fault message="ns:WS_UsuarioSQLException" name="WS_UsuarioSQLException" wsaw:Action="urn:excluirUsuarioWS_UsuarioSQLException"/>
</wsdl:operation>
<wsdl:operation name="atualizarUsuario">
<wsdl:input message="ns:atualizarUsuarioRequest" wsaw:Action="urn:atualizarUsuario"/>
<wsdl:output message="ns:atualizarUsuarioResponse" wsaw:Action="urn:atualizarUsuarioResponse"/>
<wsdl:fault message="ns:WS_UsuarioSQLException" name="WS_UsuarioSQLException" wsaw:Action="urn:atualizarUsuarioWS_UsuarioSQLException"/>
</wsdl:operation>
<wsdl:operation name="inserirUsuario">
<wsdl:input message="ns:inserirUsuarioRequest" wsaw:Action="urn:inserirUsuario"/>
<wsdl:output message="ns:inserirUsuarioResponse" wsaw:Action="urn:inserirUsuarioResponse"/>
<wsdl:fault message="ns:WS_UsuarioSQLException" name="WS_UsuarioSQLException" wsaw:Action="urn:inserirUsuarioWS_UsuarioSQLException"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="WS_UsuarioSoap11Binding" type="ns:WS_UsuarioPortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="excluirUsuario">
<soap:operation soapAction="urn:excluirUsuario" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="WS_UsuarioSQLException">
<soap:fault use="literal" name="WS_UsuarioSQLException"/>
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="atualizarUsuario">
<soap:operation soapAction="urn:atualizarUsuario" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="WS_UsuarioSQLException">
<soap:fault use="literal" name="WS_UsuarioSQLException"/>
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="inserirUsuario">
<soap:operation soapAction="urn:inserirUsuario" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
<wsdl:fault name="WS_UsuarioSQLException">
<soap:fault use="literal" name="WS_UsuarioSQLException"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="WS_UsuarioSoap12Binding" type="ns:WS_UsuarioPortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="excluirUsuario">
<soap12:operation soapAction="urn:excluirUsuario" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
<wsdl:fault name="WS_UsuarioSQLException">
<soap12:fault use="literal" name="WS_UsuarioSQLException"/>
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="atualizarUsuario">
<soap12:operation soapAction="urn:atualizarUsuario" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
<wsdl:fault name="WS_UsuarioSQLException">
<soap12:fault use="literal" name="WS_UsuarioSQLException"/>
</wsdl:fault>
</wsdl:operation>
<wsdl:operation name="inserirUsuario">
<soap12:operation soapAction="urn:inserirUsuario" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
<wsdl:fault name="WS_UsuarioSQLException">
<soap12:fault use="literal" name="WS_UsuarioSQLException"/>
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="WS_UsuarioHttpBinding" type="ns:WS_UsuarioPortType">
<http:binding verb="POST"/>
<wsdl:operation name="excluirUsuario">
<http:operation location="excluirUsuario"/>
<wsdl:input>
<mime:content type="application/xml" part="parameters"/>
</wsdl:input>
<wsdl:output>
<mime:content type="application/xml" part="parameters"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="atualizarUsuario">
<http:operation location="atualizarUsuario"/>
<wsdl:input>
<mime:content type="application/xml" part="parameters"/>
</wsdl:input>
<wsdl:output>
<mime:content type="application/xml" part="parameters"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="inserirUsuario">
<http:operation location="inserirUsuario"/>
<wsdl:input>
<mime:content type="application/xml" part="parameters"/>
</wsdl:input>
<wsdl:output>
<mime:content type="application/xml" part="parameters"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="WS_Usuario">
<wsdl:port name="WS_UsuarioHttpSoap11Endpoint" binding="ns:WS_UsuarioSoap11Binding">
<soap:address location="http://localhost:8009/ExemploWS/services/WS_Usuario.WS_UsuarioHttpSoap11Endpoint/"/>
</wsdl:port>
<wsdl:port name="WS_UsuarioHttpSoap12Endpoint" binding="ns:WS_UsuarioSoap12Binding">
<soap12:address location="http://localhost:8009/ExemploWS/services/WS_Usuario.WS_UsuarioHttpSoap12Endpoint/"/>
</wsdl:port>
<wsdl:port name="WS_UsuarioHttpEndpoint" binding="ns:WS_UsuarioHttpBinding">
<http:address location="http://localhost:8009/ExemploWS/services/WS_Usuario.WS_UsuarioHttpEndpoint/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

Console error

[ERROR] Exception occurred while trying to invoke service method insert Your name org.apache.axis2.Axisfault: br.com.Sata.Classes.Usuario at org.apache.axis2.AxisFault.makeFault(Axisfault.java:430) at org.apache.axis2.engine.Defaultobjectsupplier.getObject(Defaultobjectsupplier.java:47) at org.apache.axis2.databinding.utils.BeanUtil.deserialize(Beanutil.java:412) at org.apache.axis2.databinding.utils.BeanUtil.processObject(Beanutil.java:818) at org.apache.axis2.databinding.utils.BeanUtil.Processelement(Beanutil.java:737) at org.apache.axis2.databinding.utils.BeanUtil.deserialize(Beanutil.java:646) at org.apache.axis2.rpc.receivers.RPCUtil.processRequest(Rpcutil.java:153) at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(Rpcutil.java:206) at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(Rpcmessagereceiver.java:117) at org.apache.axis2.receivers.Abstractinoutmessagereceiver.invokeBusinessLogic(Abstractinoutmessagereceiver.java:40) at org.apache.axis2.receivers.Abstractmessagereceiver.receive(Abstractmessagereceiver.java:114) at org.apache.axis2.engine.Axisengine.receive(Axisengine.java:181) at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(Httptransportutils.java:172) at org.apache.axis2.transport.http.AxisServlet.doPost(Axisservlet.java:146) at javax.servlet.http.HttpServlet.service(Httpservlet.java:643) at javax.servlet.http.HttpServlet.service(Httpservlet.java:723) at org.apache.Applicationfilterchain.internalDoFilter(Applicationfilterchain.java:290) at org.apache.Catalina.core.Applicationfilterchain.doFilter(Applicationfilterchain.java:206) at org.apache.Catalina.core.Standardwrappervalve.invoke(Standardwrappervalve.java:233) at org.apache.Catalina.core.Standardcontextvalve.invoke(Standardcontextvalve.java:191) at org.apache.Catalina.core.Standardhostvalve.invoke(Standardhostvalve.java:127) at org.apache.Catalina.valves.Errorreportvalve.invoke(Errorreportvalve.java:103) at org.apache.Catalina.core.Standardenginevalve.invoke(Standardenginevalve.java:109) at org.apache.Catalina.connector.Coyoteadapter.service(Coyoteadapter.java:293) at org.apache.Coyote.http11.Http11processor.process(Http11processor.java:861) at org.apache.Coyote.http11.Http11protocol$Http11connectionhandler.process(Http11protocol.java:620) at org.apache.Tomcat.util.net.Jioendpoint$Worker.run(Jioendpoint.java:489) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.Instantiationexception: br.com.Sata.Classes.Usuario at java.lang.Class.newInstance(Unknown Source) at org.apache.axis2.engine.Defaultobjectsupplier.getObject(Defaultobjectsupplier.java:42) ... 26 more Caused by: java.lang.Nosuchmethodexception: br.com.Sata.Classes.Usuario.() at java.lang.Class.getConstructor0(Unknown Source) ... 28 more

How can I fix this? and this will affect all other scripts that are in a package other than the web service? or only scripts that are used as parameters in web service methods?

  • 2

    It is correct the Imports in your webservice?

  • If you speak of the Java code Imports I put, so much that in the code there is no error, the problem is at the time of consuming the web service, I put the Java code and XML to be able to better visualize the problem

  • Puts a try/catch in your method instead of giving throws and see if there’s something going on.

  • but the message remains the same

  • You have to look if he got in the catch, got in?

  • "does not access the classes" ? ?

  • He did not catch, otherwise he would have given another answer, I put a Return in the catch for e.getMensage

  • It’s like public?

  • Yeah, the only thing you have is inheritance, but I had tested it before with inheritance and it was working

Show 4 more comments

1 answer

1

I was able to solve guys, the problem was that it was missing to put an empty constructor in the class, I do not know why this happens but that was what was causing the error, maybe because at the time it incites it asks for the values, so I left one constructor empty for first and another normal to enter the data

package br.com.sata.Classes;

public class Usuario extends Infos
{
    private String login;
    private String senha;

    public Usuario()
    {

    }

    public Usuario(int id, String nome, String email, String cp,
            int idCidadeFK, String bairro, String rua, int numero,
            String complemento, double reputacao, String telefone,
            String celular, int conc, int canc, String login, String senha) {
        super(id, nome, email, cp, idCidadeFK, bairro, rua, numero,
                complemento, reputacao, telefone, celular, conc, canc);
        this.login = login;
        this.senha = senha;
    }

}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.