diff options
author | nash <nash@13f79535-47bb-0310-9956-ffa450edef68> | 2010-09-27 12:03:37 +0000 |
---|---|---|
committer | nash <nash@13f79535-47bb-0310-9956-ffa450edef68> | 2010-09-27 12:03:37 +0000 |
commit | 6ef3a489ca517939794415e21258e91a7b7c7239 (patch) | |
tree | 7ff2bff4f8397aefc494947f2499b4cee9b22b4f /sca-java-1.x/branches/sca-java-1.6.1/demos/xml-bigbank | |
parent | f4a3d3cb6ef9ff0c9cef1c69eb8099c3263ee4f6 (diff) |
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
Diffstat (limited to 'sca-java-1.x/branches/sca-java-1.6.1/demos/xml-bigbank')
3 files changed, 59 insertions, 15 deletions
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 diff --git a/sca-java-1.x/branches/sca-java-1.6.1/demos/xml-bigbank/src/main/resources/BigBank.composite b/sca-java-1.x/branches/sca-java-1.6.1/demos/xml-bigbank/src/main/resources/BigBank.composite index 18f848fdcb..8afde4bf80 100644 --- a/sca-java-1.x/branches/sca-java-1.6.1/demos/xml-bigbank/src/main/resources/BigBank.composite +++ b/sca-java-1.x/branches/sca-java-1.6.1/demos/xml-bigbank/src/main/resources/BigBank.composite @@ -45,8 +45,7 @@ </component>
<reference name="StockQuoteReference" promote="AccountService/stockQuote">
- <binding.ws wsdlElement="http://bigbank/#wsdl.port(StockQuoteService/StockQuotePort)" />
- <!--binding.ws wsdlElement="http://www.webserviceX.NET/#wsdl.port(StockQuote/StockQuoteSoap)" /-->
+ <binding.ws wsdlElement="http://www.webserviceX.NET/#wsdl.port(StockQuote/StockQuoteSoap)" />
</reference>
</composite>
diff --git a/sca-java-1.x/branches/sca-java-1.6.1/demos/xml-bigbank/src/main/resources/wsdl/StockQuotes.wsdl b/sca-java-1.x/branches/sca-java-1.6.1/demos/xml-bigbank/src/main/resources/wsdl/StockQuotes.wsdl index 26000e4480..7af2b6793b 100644 --- a/sca-java-1.x/branches/sca-java-1.6.1/demos/xml-bigbank/src/main/resources/wsdl/StockQuotes.wsdl +++ b/sca-java-1.x/branches/sca-java-1.6.1/demos/xml-bigbank/src/main/resources/wsdl/StockQuotes.wsdl @@ -1,31 +1,66 @@ -<?xml version="1.0" encoding="UTF-8" ?>
-<wsdl:definitions name="StockQuoteService" targetNamespace="http://bigbank/" xmlns:tns="http://bigbank/"
- xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:wsx="http://www.webserviceX.NET/" xmlns:SOAP="http://schemas.xmlsoap.org/wsdl/soap/">
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+
+<!--
+ Ideally we would obtain the WSDL from the remote server using <wsdl:import location="..."/>, but this
+ causes major problems if the server is down because the unresolved import causes the contribution load
+ to fail. A simple workaround is to use a local WSDL definition that matches the service we are attempting
+ to invoke. This ensures that the contribution can always be loaded. If the service invocation fails at
+ runtime because the server is down, there is code in the demo to catch the exception and use local
+ historical data instead.
+ -->
+
+<!-- If you're feeling brave, uncomment the following and comment out the local definition below
+<wsdl:definitions targetNamespace="http://www.webserviceX.NET/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+ <wsdl:import namespace="http://www.webserviceX.NET/"
+ location="http://www.webservicex.net/stockquote.asmx?wsdl" />
+</wsdl:definitions>
+-->
+
+<!-- This is the local definition for the remote web service -->
+<wsdl:definitions targetNamespace="http://www.webserviceX.NET/" xmlns:tns="http://www.webserviceX.NET/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:SOAP="http://schemas.xmlsoap.org/wsdl/soap/">
<wsdl:types>
- <xs:schema attributeFormDefault="qualified" elementFormDefault="unqualified"
+ <xs:schema attributeFormDefault="qualified" elementFormDefault="qualified"
targetNamespace="http://www.webserviceX.NET/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="GetQuoteResponse">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="return" nillable="true" type="xs:string" />
+ <xs:element minOccurs="0" name="GetQuoteResult" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="GetQuote">
<xs:complexType>
<xs:sequence>
- <xs:element minOccurs="0" name="GetQuoteResult" nillable="true" type="xs:string" />
+ <xs:element minOccurs="0" name="symbol" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name="GetQuoteResponse">
- <wsdl:part name="GetQuoteResponse" element="wsx:GetQuoteResponse" />
+ <wsdl:part name="GetQuoteResponse" element="tns:GetQuoteResponse" />
</wsdl:message>
<wsdl:message name="GetQuote">
- <wsdl:part name="GetQuote" element="wsx:GetQuote" />
+ <wsdl:part name="GetQuote" element="tns:GetQuote" />
</wsdl:message>
<wsdl:portType name="StockQuote">
<wsdl:operation name="GetQuote">
@@ -45,8 +80,8 @@ </wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="StockQuoteService">
- <wsdl:port name="StockQuotePort" binding="tns:StockQuoteBinding">
+ <wsdl:service name="StockQuote">
+ <wsdl:port name="StockQuoteSoap" binding="tns:StockQuoteBinding">
<SOAP:address location="http://www.webservicex.net/stockquote.asmx" />
</wsdl:port>
</wsdl:service>
|