From 6ef3a489ca517939794415e21258e91a7b7c7239 Mon Sep 17 00:00:00 2001 From: nash Date: Mon, 27 Sep 2010 12:03:37 +0000 Subject: TUSCANY-3690: Improve eror handling and fix problems with local WSDL git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1001690 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/bigbank/AccountServiceImpl.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'sca-java-1.x/branches/sca-java-1.6.1/demos/xml-bigbank/src/main/java/bigbank/AccountServiceImpl.java') diff --git a/sca-java-1.x/branches/sca-java-1.6.1/demos/xml-bigbank/src/main/java/bigbank/AccountServiceImpl.java b/sca-java-1.x/branches/sca-java-1.6.1/demos/xml-bigbank/src/main/java/bigbank/AccountServiceImpl.java index 46995de393..c2d0e8ab01 100644 --- a/sca-java-1.x/branches/sca-java-1.6.1/demos/xml-bigbank/src/main/java/bigbank/AccountServiceImpl.java +++ b/sca-java-1.x/branches/sca-java-1.6.1/demos/xml-bigbank/src/main/java/bigbank/AccountServiceImpl.java @@ -78,7 +78,17 @@ public class AccountServiceImpl implements AccountService { try { OMElement quotes = stockQuote.GetQuote(request); xml = quotes.getText(); + if (!xml.startsWith("<")) { + System.out.println("Server responded: " + xml); + throw new IllegalStateException("Unexpected response from server"); + } } catch (Exception e) { + if (e.getMessage().contains("Transport error: 503")) { + // server is down, use local historical data + } else { + // report any other errors + throw e; + } // restore the previous logging setting } finally { @@ -87,8 +97,8 @@ public class AccountServiceImpl implements AccountService { // if the web service invocation was successful, process the response XMLStreamReader qts = null; - if (xml != null && xml.startsWith("<")) { - System.out.println(xml); + if (xml != null) { + System.out.println("Server responded: " + xml); qts = factory.createXMLStreamReader(new StringReader(xml)); // if the web service isn't responding, continue with the demo using historical data -- cgit v1.2.3