You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Trent Bartlem (JIRA)" <ji...@apache.org> on 2009/02/25 05:59:04 UTC
[jira] Commented: (AXIS2-4252) Axis2-xmlbean stub doesn't set
exception.message on custom soap faults
[ https://issues.apache.org/jira/browse/AXIS2-4252?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12676503#action_12676503 ]
Trent Bartlem commented on AXIS2-4252:
--------------------------------------
er,
exceptionClass.getConstructor(String.class).newInstance(f.getMessage())
should be
exceptionClass.getConstructor(new Class[]{String.class}).newInstance(new Object[]{f.getMessage()})
for pre-Java 5 implementation
> Axis2-xmlbean stub doesn't set exception.message on custom soap faults
> ----------------------------------------------------------------------
>
> Key: AXIS2-4252
> URL: https://issues.apache.org/jira/browse/AXIS2-4252
> Project: Axis 2.0 (Axis2)
> Issue Type: Improvement
> Components: client-api, codegen, databinding
> Affects Versions: 1.4.1
> Environment: Linux
> Reporter: Trent Bartlem
> Priority: Minor
> Original Estimate: 2h
> Remaining Estimate: 2h
>
> Axis2 provides implementation subclasses of org.apache.axis2.client.Stub when it generates from WSDL.
> An example WSDL snippet would be:
> <wsdl:operation name="quote" parameterOrder="booking">
> <wsdl:input name="quoteRequest" message="impl:quoteRequest" />
> <wsdl:output name="quoteResponse" message="impl:quoteResponse" />
> <wsdl:fault name="ValidationException" message="impl:ValidationException" />
> </wsdl:operation>
> When the server-side code is called and fails validation, it returns this soap message, which conforms to the above operation. (the ValidationMessage element is specified in the WSDL as a return element, but its structure isn't important)
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
> <soapenv:Body>
> <soapenv:Fault>
> <faultcode>soapenv:Server</faultcode>
> <faultstring>Missing field: Address line1</faultstring>
> <detail>
> <ValidationMessage xmlns="http://custom.example.org">You are missing a required field.</ValidationMessage>
> </detail>
> </soapenv:Fault>
> </soapenv:Body>
> </soapenv:Envelope>
> However, the unmarshalled org.example.custom.ValidationException() that is thrown from the axis2 client does not have the exception message set.
> The section of the client stub that's responsible for unmarshalling the exception looks like this:
> try {
> // snip
> //execute the operation client
> // snip
> }
> }catch(org.apache.axis2.AxisFault f){
> org.apache.axiom.om.OMElement faultElt = f.getDetail();
> if (faultElt!=null){
> if (faultExceptionNameMap.containsKey(faultElt.getQName())){
> //make the fault by reflection
> try{
> java.lang.String exceptionClassName = (java.lang.String)faultExceptionClassNameMap.get(faultElt.getQName());
> java.lang.Class exceptionClass = java.lang.Class.forName(exceptionClassName);
> java.lang.Exception ex=
> (java.lang.Exception) exceptionClass.newInstance();
> //message class
> java.lang.String messageClassName = (java.lang.String)faultMessageMap.get(faultElt.getQName());
> java.lang.Class messageClass = java.lang.Class.forName(messageClassName);
> java.lang.Object messageObject = fromOM(faultElt,messageClass,null);
> java.lang.reflect.Method m = exceptionClass.getMethod("setFaultMessage",
> new java.lang.Class[]{messageClass});
> m.invoke(ex,new java.lang.Object[]{messageObject});
>
> if (ex instanceof org.example.custom.ValidationException){
> throw (org.example.custom.ValidationException)ex;
> }
> // snip rest of method
> The problem is due to the generated line :
> java.lang.Exception ex=
> (java.lang.Exception) exceptionClass.newInstance();
> This doesn't set the exception message.
> Perhaps the code generation could be changed to output
> java.lang.Exception ex=
> (java.lang.Exception) exceptionClass.getConstructor(String.class).newInstance(f.getMessage());
> instead?
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.