Announcement Announcement Module
Collapse
No announcement yet.
Elegant way to handle soap error when calling as client Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Elegant way to handle soap error when calling as client

    Hi,

    I have read some of the articles and doc, and I am still not sure about the best way to handle soap errors on the client side,

    I receive an xml message and I start a new thread in this thread,

    I have marshalling / unmarchalling and send back an xml message.

    Response response = (Response) webServiceTemplate
    .marshalSendAndReceive(report, new WebServiceMessageCallback() {

    public void doWithMessage(WebServiceMessage message) {
    //inside here I am logging the outgoind message
    }});



    I would like to do very professional error handling here.

    so that I can log if something goes wrong

    also this is how I invoke it:

    try {
    response = this.processDeliverService.getWebserviceclient().s endAndRecive(report);
    logger.debug("run() - response:" + response);
    isMessageSent = true;
    log.setResponse(response.toString());
    } catch (IOException e) {
    logger.fatal("run() - IO exception:", e);
    fatalMessage = "Unable to receive answer from the ESPOKE / EHUB system: "+ e.getMessage();
    } catch (WebServiceTransportException e) {
    //Thrown when the Transport is not working properly
    logger.fatal("run() - Web transport layer exception:", e);
    fatalMessage = "Web transport layer exception while talking to ESPOKE / EHUB system: "+ e.getMessage();
    } catch (SoapFaultClientException e) {
    //thrown when the SOAP answer is error
    logger.fatal("run() - SOAP transport layer exception, reason:" + e.getFaultStringOrReason(), e);
    fatalMessage = "SOAP transport layer exception while talking to ESPOKE / EHUB system: " + e.getFaultStringOrReason() + " , error: " +e.getMessage();
    String resp = e.getFaultCode() +" "+ e.getFaultStringOrReason();
    log.setResponse(resp);
    } finally {

    };

    How could I refactor the error handling from code where I call the client,

    Thanks for any advice,

    ps: I read in the doc that you can also define error hanlers, but I am not sure what is the best in this case to have a really robust error prone handling which always works,

    also I have the problem that the webservice I am talking to sends back 200 with a SOAP-error message inside, I know according tot he spec this should be 5xx + SOAP-Error, although this is an old service I can not change, and at the moment, I receive an unmarshalling exception saying that the root element of the message is illegal ( Of course as it expects a ack. respone message when it is a 202, or 200

    Any ideas ?
Working...
X