0

Good day

I have been searching the web, and so far the following solution seems the closest i can get to a solution without any 3rd party libraries but it doesn't work. :(

I do not have a wsdl I can stub. I am calling an external webservice and simply passing in a soap message.

I tested the same code using no container, ie. in a main method in my ide and it works there, when i deploy to wildfly10 it looks like its being ignored or overridden by jboss.

I cannot find any properties in the standalone.xml to edit to change readtimeout settings and it needs to be for this webservice call only.

My debugging LOG doesn't print anything to the logs which suggests it isn't being executed. I am expecting an immediate error because of the setReadTimeout(1);

Anyone with any ideas?

SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
SOAPConnection soapConnection = soapConnectionFactory.createConnection();
URL endpoint = new URL (null, ENDPOINT, new URLStreamHandler() {    
        @Override
        protected URLConnection openConnection(URL u) throws IOException {
            LOG.debug("1.");
             URL clone = new URL (u.toString ());
             LOG.debug("2.");
             URLConnection connection = clone.openConnection ();
             LOG.debug("3.");
             connection.setConnectTimeout (10000);//10 seconds 
             LOG.debug("4.");
             connection.setReadTimeout (1);//1 ms
             LOG.debug("5.");
            return connection;
        }
    });

    SOAPMessage soapResponse = soapConnection.call(soapMsg, endpoint);

If i edit the call line to the following, the readtimeout works, but i get http 500,but the url is correct:

SOAPMessage soapResponse = soapConnection.call(soapMsg, endpoint.getContent());
kwm
  • 29
  • 4
  • Are you by any chance trying to print out the content of your SOAP message before making the call ? – mwangi Nov 01 '16 at 15:57
  • I am actually. I log the whole message before sending it, for debugging purposes. – kwm Nov 01 '16 at 16:19
  • Don't log the messages before sending it. For some reason that clears your soap message. Comment out any code that logs or prints out the SOAP message before sending it out first. This should now work. – mwangi Nov 02 '16 at 07:11
  • I removed every bit of logging in the app. Still wont work. I am not sure what you mean by clears the soap message? – kwm Nov 02 '16 at 09:00
  • How were you logging the soapMsg before removing ? – mwangi Nov 02 '16 at 11:05
  • Copied the soap message,wrtoe to bytearrayoutputstream,wrote that to string as utf-8. Logged that string using slf4j Logger – kwm Nov 04 '16 at 10:11

1 Answers1

0

Don't log the messages before sending it. For some reason that clears your soap message. Comment out any code that logs or prints out the SOAP message before sending it out first. This should now work.

mwangi
  • 1,616
  • 1
  • 20
  • 23