Forum Discussion

Sjakie's avatar
Occasional Contributor
10 years ago

Exception is not caught



As I try to send a message to my System Under Test, I get a HttpHostConnectException when the system is not availble. I would like to catch the exception and handle it properly. Unfortunatly somehow this does not work. I use SoapUI Pro 5.1.2 on a Windows 7 Pro machine.


If use the following code:

public String sendMessage(String strAddress, String strMessageToSend) {
    String strMessage;
    StringToObjectMap map = new StringToObjectMap()

    map.put("address",, "UTF-8"));    //retrieve url to send to
    //Send message
    WsdlTestSuitePro tsWsdlTSP = context.getMockService().getProject().getTestSuiteByName("TestSuite");
    WsdlTestCasePro tcWsdlTCP = tsWsdlTSP.getTestCaseByName("TestCase");
    WsdlTestRequestStep trWSDLtrs = (WsdlTestRequestStep) tcWsdlTCP.getTestStepsOfType(WsdlTestRequestStep.class).get(0);
    //replace message with one that is given
    //add the desired address
    //def runner =, true);
    TestCaseRunner runner = null;
    try {
        runner =, false); //wait for an answer"Sim: Message sent to Consumer");
//    catch(HttpHostConnectException hhce) {
//        //hhce.printStackTrace();
//        log.error("hhce: " + hhce.getMessage() );
//        strMessage = hhce.getMessage();
//    }
    catch(Exception e) {
        log.error("Exception: " + e.getMessage() );
        strMessage = e.getMessage();

    if (runner == null ) {
        strMessage = "An error has occured: " +strMessage
    else if (runner.getStatus().toString().equals("FINISHED") ){
        strMessage = "OK"
    else {
        strMessage = runner.getReason();
    return strMessage;


My logging prints the line "Sim: Message sent to Consumer". The error logging shows the complete stacktrace, The stacktrace refers to the line "runner =, false); //wait for an answer".


Why is the exception not caught? Is there any other way of doing this? I just want to return the message of the HttpHostConnectException.


Thanks in advance!

4 Replies

  • nmrao's avatar
    Champion Level 3
    Are you sure if it is HttpHostConnectException? Or it ?
    • Sjakie's avatar
      Occasional Contributor

      Yes, because that is what is in the error log where the StackTrace is shown.


      To be sure, I had added an extra catch-part for Exception as can be seen in the code.

      • nmrao's avatar
        Champion Level 3
        Would like to catch the exception in this order UnknownHostException, HttpHostConnectException and then Exception to see if that helps?