5
respostas

Não consigo rodar a aplicação como um recurso no servidor

Estou tentando criar um cliente para fazer uma chamada SOAP a partir de um WSDL. Escrevi esse código para testar, usando classes geradas pelo wsdl2java a partir do meu WSDL, mas não consegui rodar, diz que o recurso não pode rodar no servidor.

Já tentei criar um Java EE Projetc, Maven Project e Java project. mas não tive sucesso em nenhum. Heeelp!

public class ReanaliseClient {

    public static void main(String[] args) {

        ReanaliseService client = new ReanaliseService();
        VerificarDispReanalise reanalise = new VerificarDispReanalise();
        VerificaDispReanaliseRequest request = new VerificaDispReanaliseRequest();

        JAXBElement<String> cpf = null;
        cpf.setValue("31874249881");

        JAXBElement<String> chapa = null;
        chapa.setValue("107799");


        request.setCPF(cpf);
        request.setChapa(chapa);
        client.getBasicHttpBindingReanaliseService();

    }

}
5 respostas

Opa, consegue postar a exception para a gente aqui?

Passei a tentar rodar normal como uma Java Aplication e Mudei o código para:

@WebServiceClient
public class ReanaliseClient {

    public static void main(String[] args) throws ReanaliseServiceVerificarDispReanaliseCustomExceptionFaultFaultMessage {

        ReanaliseService client = new ReanaliseService();
    VerificarDispReanalise reanalise = new VerificarDispReanalise();
    static VerificaDispReanaliseRequest request = new VerificaDispReanaliseRequest();
    VerificaDispReanaliseResponse response = new VerificaDispReanaliseResponse();

    ireanaliseservice.realizews.conductor.com.br.ObjectFactory objectFactory = new ireanaliseservice.realizews.conductor.com.br.ObjectFactory();
    ObjectFactory oF = new ObjectFactory();

        request.setCPF(oF.createString("06721092638"));
        request.setChapa(oF.createString("112242"));
        JAXBElement<VerificaDispReanaliseRequest> requestJAX = objectFactory.createVerificarDispReanaliseReq(request);
        response =  client.getBasicHttpBindingReanaliseService().verificarDispReanalise(requestJAX.getValue());
        return  response;
    }
}

E obtive a seguinte exception:

IINFORMAÇÕES: Creating Service {http://tempuri.org/}ReanaliseService from WSDL: file:/C:/Users/icaro.prates/Documents/Projetos/Reanalise/wsdl/ReanaliseService.xml
Exception in thread "main" ireanaliseservice.realizews.conductor.com.br.ReanaliseServiceVerificarDispReanaliseCustomExceptionFaultFaultMessage: Object reference not set to an instance of an object.
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.apache.cxf.interceptor.ClientFaultConverter.processFaultDetail(ClientFaultConverter.java:183)
    at org.apache.cxf.interceptor.ClientFaultConverter.handleMessage(ClientFaultConverter.java:83)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
    at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:112)
    at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:70)
    at org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:35)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
    at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:833)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1695)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1572)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1373)
    at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
    at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:673)
    at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:63)
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
    at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:537)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:446)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:361)
    at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:319)
    at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:96)
    at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:139)
    at com.sun.proxy.$Proxy45.verificarDispReanalise(Unknown Source)
    at client.ReanaliseClient.verificarDispReanalise(ReanaliseClient.java:42)
    at client.ReanaliseClient.main(ReanaliseClient.java:67)

Por favor, alguma ajuda?

Opa Icaro, perdão por não ter continuado no tópico depois da sua exception. Eu não sei exatamente o motivo dessa exception. Dando uma pesquisada, parece.que você está deixando de passar algum parâmetro que o serviço espera... Mas é apenas um chute.

Como eu desconfiava era problema de proxy. Consegui passar o proxy usando o System.setProperty. Porém agora está retornando a seguinte Exception:

jul 05, 2018 4:37:15 PM org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean buildServiceFromWSDL
INFORMAÇÕES: Creating Service {http://tempuri.org/}ReanaliseService from WSDL: file:/C:/Users/icaro.prates/Documents/Projetos/Reanalise/wsdl/ReanaliseService.xml
Exception in thread "main" javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
    at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:361)
    at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:350)
    at javax.xml.ws.Service.getPort(Service.java:119)
    at org.tempuri.ReanaliseService.getBasicHttpBindingReanaliseService(ReanaliseService.java:72)
    at client.ReanaliseClient.verificarDispReanalise(ReanaliseClient.java:48)
    at client.ReanaliseClient.main(ReanaliseClient.java:73)
Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
    at org.apache.cxf.wsdl11.WSDLServiceFactory.create(WSDLServiceFactory.java:169)
    at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:408)
    at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:528)
    at org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:263)
    at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:199)
    at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:103)
    at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:91)
    at org.apache.cxf.frontend.ClientProxyFactoryBean.create(ClientProxyFactoryBean.java:159)
    at org.apache.cxf.jaxws.JaxWsProxyFactoryBean.create(JaxWsProxyFactoryBean.java:142)
    at org.apache.cxf.jaxws.ServiceImpl.createPort(ServiceImpl.java:493)
    at org.apache.cxf.jaxws.ServiceImpl.getPort(ServiceImpl.java:359)
    ... 5 more
Caused by: org.apache.ws.commons.schema.XmlSchemaException: Unable to locate imported document at 'http://10.60.30.148:26091/Services/ReanaliseService.svc?xsd=xsd0', relative to 'http://10.60.30.148:26091/Services/ReanaliseService.svc?wsdl=wsdl0#types1'.
    at org.apache.cxf.catalog.CatalogXmlSchemaURIResolver.resolveEntity(CatalogXmlSchemaURIResolver.java:76)
    at org.apache.ws.commons.schema.SchemaBuilder.resolveXmlSchema(SchemaBuilder.java:684)
    at org.apache.ws.commons.schema.SchemaBuilder.handleImport(SchemaBuilder.java:538)
    at org.apache.ws.commons.schema.SchemaBuilder.handleSchemaElementChild(SchemaBuilder.java:1513)
    at org.apache.ws.commons.schema.SchemaBuilder.handleXmlSchemaElement(SchemaBuilder.java:659)
    at org.apache.ws.commons.schema.XmlSchemaCollection.read(XmlSchemaCollection.java:540)
    at org.apache.cxf.common.xmlschema.SchemaCollection.read(SchemaCollection.java:129)
    at org.apache.cxf.wsdl11.SchemaUtil.extractSchema(SchemaUtil.java:141)
    at org.apache.cxf.wsdl11.SchemaUtil.getSchemas(SchemaUtil.java:82)
    at org.apache.cxf.wsdl11.SchemaUtil.getSchemas(SchemaUtil.java:66)
    at org.apache.cxf.wsdl11.SchemaUtil.getSchemas(SchemaUtil.java:61)
    at org.apache.cxf.wsdl11.WSDLServiceBuilder.getSchemas(WSDLServiceBuilder.java:378)
    at org.apache.cxf.wsdl11.WSDLServiceBuilder.buildServices(WSDLServiceBuilder.java:345)
    at org.apache.cxf.wsdl11.WSDLServiceBuilder.buildServices(WSDLServiceBuilder.java:209)
    at org.apache.cxf.wsdl11.WSDLServiceFactory.create(WSDLServiceFactory.java:161)
    ... 15 more

:(