java error running via jar

0

I have a code that makes a request to a WS. When I run via NetBeans, the code works perfectly, but when I do via java -jar programa.jar the system has the following error:

     com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection post
GRAVE: SAAJ0008: Resposta Incorreta; Bad Request
Exception in thread "main" com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (400Bad Request
        at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call(Unknown Source)
        at ws.WS.main(WS.java:86)
Caused by: com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (400Bad Request
        at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.post(Unknown Source)
        ... 2 more

CAUSE:

com.sun.xml.internal.messaging.saaj.SOAPExceptionImpl: Bad response: (400Bad Request
        at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.post(Unknown Source)
        at com.sun.xml.internal.messaging.saaj.client.p2p.HttpSOAPConnection.call(Unknown Source)
        at ws.WS.main(WS.java:86)

Code:

if(tipo == 1){ // CAN
            System.out.println("Iniciando cancelamento");
            SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
            SOAPConnection soapConnection = soapConnectionFactory.createConnection();
            String url = "MINHAURL.svc?wsdl";
            MimeHeaders headers = new MimeHeaders();
            headers.addHeader("Content-Type", "text/xml");    
            headers.addHeader("SOAPAction", "hXXXXXX/Cancela"); 

            MessageFactory messageFactory = MessageFactory.newInstance();

            SOAPMessage msg = null;
            try {
                msg = messageFactory.createMessage(headers, (new ByteArrayInputStream(requestSoap.getBytes())));
            } catch (IOException ex) {
                Logger.getLogger(WS.class.getName()).log(Level.SEVERE, null, ex);
            }

            SOAPMessage soapResponse = soapConnection.call(msg, url);
            Document xmlRespostaARequisicao=soapResponse.getSOAPBody().getOwnerDocument();
            System.out.println(passarXMLParaString(xmlRespostaARequisicao,4));
            gerarArquivoRetorno(passarXMLParaString(xmlRespostaARequisicao,4));

        }

Line 86 would be:

SOAPMessage soapResponse = soapConnection.call(msg, url);
    
asked by anonymous 26.12.2016 / 18:15

0 answers