1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
|
<!--
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.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<!-- generateKeywords macro -->
<META name="description" content="Apache Tuscany">
<META name="keywords" content="apache, apache tuscany, tuscany, service, services, fabric, soa, service oriented architecture, sca, service component architecture, das, sdo, csa, ruby, opensource">
<!-- generateKeywords macro end -->
<LINK type="text/css" rel="stylesheet" href="http://tuscany.apache.org/stylesheets/default.css">
<LINK rel="SHORTCUT ICON" href="https://cwiki.apache.org/confluence/display/TUSCANY/$images/favicon.ico">
<TITLE>Apache Tuscany : BusinessExceptions</TITLE>
<META http-equiv="Content-Type" content="text/html;charset=UTF-8"></HEAD>
<BODY onload="init()">
<!-- topNav macro -->
<TABLE valign="top" border="0" cellspacing="0" cellpadding="0" width="100%" background="http://tuscany.apache.org/images/TuscanyLogoNEW_Text_120px_bg.jpg">
<TR>
<TD valing="top" align="left">
<A href="https://cwiki.apache.org/confluence/pages/viewpage.action?spaceKey=TUSCANY&title=$siteroot"><IMG src="http://tuscany.apache.org/images/TuscanyLogoNEW_Text_120px_bg.jpg" height="91" width="25" border="0"></A>
</TD>
<TD>
<A href="http://tuscany.apache.org/"><IMG src="http://tuscany.apache.org/images/TuscanyLogo.jpg" border="0"></A>
</TD>
<TD width="100%">
</TD>
<!-- Adds the edit page link to the top banner-->
<TD valign="bottom">
<DIV style="padding: 2px 10px; margin: 0px;">
<A href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=43968">
<IMG src="http://tuscany.apache.org/images/notep_16.gif" height="16" width="16" border="0" align="absmiddle" title="Edit Page"></A>
</DIV>
</TD>
</TR>
</TABLE>
<!-- topNav macro end -->
<!-- breadCrumbs macro -->
<TABLE border="0" cellpadding="2" cellspacing="0" width="100%">
<TR class="topBar">
<TD align="left" valign="middle" class="topBarDiv" nowrap="true" width="100%">
<A href="home.html" title="Apache Tuscany">Apache Tuscany</A> > <A href="home.html" title="Home">Home</A> > <A href="sca-overview.html" title="SCA Overview">SCA Overview</A> > <A href="sca-java.html" title="SCA Java">SCA Java</A> > <A href="sca-java-work-in-progress.html" title="SCA Java Work-In-Progress">SCA Java Work-In-Progress</A> > <A href="" title="BusinessExceptions">BusinessExceptions</A>
</TD>
<TD align="right" valign="middle" class="topBarDiv" align="left" nowrap="true">
<A href="http://mail-archives.apache.org/mod_mbox/tuscany-user">User List</A> | <A href="http://mail-archives.apache.org/mod_mbox/tuscany-dev">Dev List</A> | <A href="http://issues.apache.org/jira/browse/Tuscany">Issue Tracker</A>
</TD>
</TR>
</TABLE>
<!-- breadCrumbs macro end -->
<TABLE border="0" cellpadding="0" width="100%" bgcolor="#FFFFFF">
<TR>
<TD align="left" valign="top">
<!-- pageContent macro -->
<DIV id="PageContent">
<DIV class="pagecontent">
<DIV class="wiki-content">
<H1><A name="BusinessExceptions-SupportingBusinessExceptionsinTuscany"></A>Supporting Business Exceptions in Tuscany</H1>
<H2><A name="BusinessExceptions-Businessexceptionrelatedconcerns"></A>Business exception related concerns</H2>
<H3><A name="BusinessExceptions-1.Howtodeclarebusinessexceptions%3F"></A>1. How to declare business exceptions?</H3>
<P>What defines business exception on each interface type. (ie Java wsdl)<BR>
In Java interface, business exceptions are declared checked exceptions specified on the operations of the services interface.<BR>
Note declared unchecked (runtime) exceptions are not considered business exceptions.<BR>
WSDL need to determine if all WSDL defined faults are business exceptions. Need to in investigate JAX-WS mapping of exceptions JAX-B databinding..<BR>
SDO has no similar specification. Need to determine a similar means for SDO to provide reliable transforms between JAX-B and SDO.</P>
<H3><A name="BusinessExceptions-2.HowtorepresentbusinessexceptionsinJava%3F"></A>2. How to represent business exceptions in Java?</H3>
<P>In Java business exception are represented as non runtime exceptions. But not all runtime exceptions delivered in a message maybe a Business exception.<BR>
If a non runtime exceptions is delivered to a component that is does not declare the exception the exception will be wrappered in a specified runtime exception.<BR>
Jax-b need to further investigate the JAX-B specification and follow how it models business exceptions as objects.<BR>
SDO there are no specific mappings provided for. May need to wrapper complex parts of an exception as SDO objects in a specific Java exception. </P>
<DIV class="panelMacro"><TABLE class="noteMacro"><COLGROUP><COL width="24"><COL></COLGROUP><TR><TD valign="top"><IMG src="https://cwiki.apache.org/confluence/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></TD><TD><B>JAX-WS WSDL1.1 to Java mapping for faults</B><BR>JAX-WS 2.0 spec defines the mapping rule for web service faults in section 2.5.</TD></TR></TABLE></DIV>
<P>Using java exception to represent the Web Service fault:</P>
<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
<PRE class="code-java">
/**
* The java exception to represent the web service fault
*/
<SPAN class="code-keyword">public</SPAN> class WebServiceFault <SPAN class="code-keyword">extends</SPAN> Exception {
<SPAN class="code-keyword">private</SPAN> <SPAN class="code-keyword">static</SPAN> <SPAN class="code-keyword">final</SPAN> <SPAN class="code-object">long</SPAN> serialVersionUID = -3134446726685504039L;
<SPAN class="code-keyword">private</SPAN> <SPAN class="code-object">Object</SPAN> fault;
<SPAN class="code-keyword">public</SPAN> WebServiceFault(<SPAN class="code-object">String</SPAN> message, <SPAN class="code-object">Object</SPAN> fault) {
<SPAN class="code-keyword">super</SPAN>(message);
<SPAN class="code-keyword">this</SPAN>.fault = fault;
}
<SPAN class="code-keyword">public</SPAN> WebServiceFault(<SPAN class="code-object">String</SPAN> message, <SPAN class="code-object">Object</SPAN> fault, Throwable cause) {
<SPAN class="code-keyword">super</SPAN>(message, cause);
<SPAN class="code-keyword">this</SPAN>.fault = fault;
}
<SPAN class="code-keyword">public</SPAN> <SPAN class="code-object">Object</SPAN> getFault() {
<SPAN class="code-keyword">return</SPAN> fault;
}
}
</PRE>
</DIV></DIV>
<H3><A name="BusinessExceptions-3.Howtotransformbusinessexceptionsacrossdatabindings%3F"></A>3. How to transform business exceptions across databindings?</H3>
<P>Provide in the data binding transformations between Axiom OMElement, SDO represented faults and JAX-B exceptions.<BR>
How to identify as business exceptions during the transforms.</P>
<H3><A name="BusinessExceptions-4.Howtopropagatebusinessexceptions%3F"></A>4. How to propagate business exceptions?</H3>
<P>Determine how to propagate exception in the Tuscany runtime message in local interactions. Make sure TargetInvocation exceptions become unwrappered<BR>
How in the case of webservice's binding propagate the message through web service binding.</P>
<H2><A name="BusinessExceptions-Ascenariototestthebusinessexceptionhandling"></A>A scenario to test the business exception handling</H2>
<H3><A name="BusinessExceptions-IntegrationTests%28iTests%29"></A>Integration Tests (iTests)</H3>
<P>Several <A href="http://svn.apache.org/repos/asf/incubator/tuscany/java/testing/sca/itest" class="external-link" rel="nofollow">integration tests</A> have been created beginning with prefix <INS>exception</INS>.</P>
<H2><A name="BusinessExceptions-Workitemsactions"></A>Work items actions</H2>
<UL>
<LI>Either investigate using existing complex type conversions or add additional interfaces to databinding framework for transformation of Exceptions.</LI>
<LI>Make SDO generated exceptions match as close as possible to JAX-B. <SUB><A href="https://cwiki.apache.org/confluence/pages/createpage.action?spaceKey=TUSCANY&title=what%20annotations%20to%20SDOs%20could%20be%20added&linkCreation=true&fromPageId=43968" class="createlink">what annotations to SDOs could be added</A></SUB></LI>
<LI>Augment Java introspector to capture JAX-B annotations in logical types to help assist in providing hints to determine matching exceptions.</LI>
<LI>Use when provided WSDL qname of Exception's message name to match exceptions. If not provided fall back to name matching and possible use of packagename annotations to resolve matching type.</LI>
<LI>Attempt to do actual conversion through Axiom transform. If conversion fails try using simple conversion through copying of respective field members.</LI>
<LI>Check that only declared checked exceptions are thrown. Wrapper all other checked exceptions.</LI>
</UL>
<H3><A name="BusinessExceptions-Questions%3A"></A>Questions:</H3>
<UL>
<LI>If the originating exception is a Business exception and conversions fails should we have a <B>Tuscany standard</B> runtime exception that will have basic message from the originating exception set ? Should we just pick one of the business exceptions on receiving operation ? This might be more robust than throwing a runtime exception.</LI>
<LI>What runtime exception should undeclared, checked exceptions be wrappered in? Tuscany defined ? just RuntimeException ? java.lang.reflect.UndeclaredThrowableException? I can see an SCA client still wanting to be "robust" capturing this and acting on it.</LI>
<LI><B>Will not directly validate webservices exceptions until axis binding is at incubator-snapshot (kernel trunk) level</B></LI>
<LI>How are we currently mapping operations during wiring in Tuscany with respect to exceptions ? Need to see if Exceptions are part of operations signature.</LI>
</UL>
<H3><A name="BusinessExceptions-ImplementationDecisions"></A>Implementation Decisions</H3>
<UL>
<LI>Currently we are unwrappering at the TargetInvokerExtension <B>all</B> exceptions and passing them on the message path.</LI>
<LI>System exceptions happening during the processing of a message are thrown up the stack.</LI>
<LI>We have made some decision on the support of SDO exception wrappers and example of can be seen in the <A href="http://svn.apache.org/repos/asf/incubator/tuscany/branches/sca-java-integration/testing/sca/itest/exceptionXbindingTest/src/main/java/org/apache/tuscany/sca/test/exceptions/sdohandgen/" class="external-link" rel="nofollow">exceptionXbindingTest iTest</A><BR>
This closely resembles the JAX-B pattern in dealing with faults. One exception is we currently have a FAULT_ELEMENT field type QName on the exception to help tie back to original wsdl element it is associate to. </LI>
</UL>
<H2><A name="BusinessExceptions-Appendix"></A>Appendix</H2>
<H3><A name="BusinessExceptions-Axis2WSDL2Java"></A>Axis2 WSDL2Java</H3>
<DIV class="code panel" style="border-width: 1px;"><DIV class="codeHeader panelHeader" style="border-bottom-width: 1px;"><B>Exception generated by Axis2 1.1</B></DIV><DIV class="codeContent panelContent">
<PRE class="code-java">
<SPAN class="code-keyword">package</SPAN> stockexceptiontestservice.scatesttool;
<SPAN class="code-keyword">public</SPAN> class InvalidSymbolFaultException <SPAN class="code-keyword">extends</SPAN> java.lang.Exception{
<SPAN class="code-keyword">private</SPAN> stockexceptiontestservice.scatesttool.InvalidSymbolFault faultMessage;
<SPAN class="code-keyword">public</SPAN> InvalidSymbolFaultException() {
<SPAN class="code-keyword">super</SPAN>(<SPAN class="code-quote">"InvalidSymbolFaultException"</SPAN>);
}
<SPAN class="code-keyword">public</SPAN> InvalidSymbolFaultException(java.lang.<SPAN class="code-object">String</SPAN> s) {
<SPAN class="code-keyword">super</SPAN>(s);
}
<SPAN class="code-keyword">public</SPAN> InvalidSymbolFaultException(java.lang.<SPAN class="code-object">String</SPAN> s, java.lang.Throwable ex) {
<SPAN class="code-keyword">super</SPAN>(s, ex);
}
<SPAN class="code-keyword">public</SPAN> void setFaultMessage(stockexceptiontestservice.scatesttool.InvalidSymbolFault msg){
faultMessage = msg;
}
<SPAN class="code-keyword">public</SPAN> stockexceptiontestservice.scatesttool.InvalidSymbolFault getFaultMessage(){
<SPAN class="code-keyword">return</SPAN> faultMessage;
}
}
</PRE>
</DIV></DIV><DIV class="panelMacro"><TABLE class="noteMacro"><COLGROUP><COL width="24"><COL></COLGROUP><TR><TD valign="top"><IMG src="https://cwiki.apache.org/confluence/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></TD><TD>The generated exception has the getter and setter for the fault: setFaultMessage(...) and getFaultMessage() and that's the pattern Axis2 adopts for web service fault to java exception mapping.
<P>The InvalidSymbolFault is a generated class to represent the fault. It can be generated using different databindings such as ADB, JAXB (and hopefully SDO in the future).</P></TD></TR></TABLE></DIV>
<H3><A name="BusinessExceptions-JAXWSRI2.1WSDL2Java"></A>JAX-WS RI 2.1 WSDL2Java</H3>
<P>Rick provided the WSDL and generated code from JAX-WS RI 2.1.</P>
<P><A href="businessexceptions.data/StockExceptionTest.wsdl">StockExceptionTest.wsdl</A></P>
<P><A href="businessexceptions.data/jaxws.wsimport.zip">jaxws.wsimport.zip</A></P>
</DIV>
</DIV>
</DIV>
<!-- pageContent macro end -->
</TD>
</TR>
</TABLE>
<!-- footer macro -->
<SCRIPT src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</SCRIPT>
<SCRIPT type="text/javascript">
_uacct = "UA-1174707-5";
urchinTracker();
</SCRIPT>
<A href="http://www.statcounter.com/" target="_blank"><IMG src="http://c26.statcounter.com/counter.php?sc_project=2619156&java=0&security=94bd7e7d&invisible=0" alt="website stats" border="0"></A>
<DIV class="footer">
Copyright � 2003-2012, The Apache Software Foundation </BR>
Apache Tuscany and the Apache Tuscany project logo are trademarks of The Apache Software Foundation.
</DIV>
<!-- footer macro end -->
</BODY>
</HTML>
|