Java error running via jar

Asked

Viewed 198 times

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 it via java -jar programa.jar the system shows 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));

        }

The line 86 would be:

SOAPMessage soapResponse = soapConnection.call(msg, url);
  • Without seeing your code you can’t be sure what the problem is. Error 404 indicates that the page he tried to access (/calculator) does not exist, but also demonstrates that something was there receiving the connection and responded to it (which is different from anyone/nothing responding to the connection).

  • I’ll post the requisition code

  • @Victorstafusa edited the error that was giving. I copied wrong to ca. Forgiveness

No answers

Browser other questions tagged

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