Thanks for your response Michael!!!

That may be useful and I was not aware of that setting however I was trying
to get axis2 to work pretty much the same way it was doing it in previous
versions. Let me explain. Axis1 whenever you expose an operation as a web
service (bottom up) it generates the wsdl:fault within the wsdl and also
places the information within the "detail" tag so it could be mapped to
whatever language you are working with in the other end. Now this is not
working this way. If you expose the same operation through axis2 the
exception would be present within the generated wsdl but no information
regarding the exception is placed within the soap fault's detail tag so
nobody will be able to deserialize anything. 

The good news is that while I was waiting for someone to come up with an
idea/clue about this issue I found out a way to create and set the tag by
declaring those methods/operations throwing AxisFault. 

This is not exactly what I was expecting and it is not my idea of a good
solution however I can get it to work. 

The code for the operation in case anyone else raise the same issue is the
following:

        public void sayHello(String str) throws AxisFault {
                //First get the message context
                MessageContext messageContext =
MessageContext.getCurrentMessageContext();

                //Create the soap factory
                SOAPFactory soapFactory = null;
                if (messageContext.isSOAP11()) {
                        soapFactory = OMAbstractFactory.getSOAP11Factory();
                } else {
                        soapFactory = OMAbstractFactory.getSOAP12Factory();
                }

                //Create the detail with an error code and message
                SOAPFaultDetail soapFaultDetail = 
soapFactory.createSOAPFaultDetail();
                QName qName = new QName("http://test";, "fault", "ns");
                OMElement detail = soapFactory.createOMElement(qName, 
soapFaultDetail);
                
                qName = new QName(null, "code", "ns");
                OMElement code = soapFactory.createOMElement(qName, null);
                code.setText("ERR-1234");
                detail.addChild(code);
                
                qName = new QName(null, "message", "ns");
                OMElement message = soapFactory.createOMElement(qName, null);
                message.setText("A readable message");
                detail.addChild(message);

                //Finally create the axis fault and populate it
                AxisFault af = new AxisFault("CustomException: The message");
                af.setDetail(detail);
                af.setFaultCode(new QName(null, "Receiver.userException", 
"soapenv"));
                
                throw af;
        }

I'd say that all this stuff should be done by axis2 itself whenever a
service operation throws a (checked) exception and this was the way it was
working and it is currently working axis1.

Please send me your comments if you have a better solution/idea.

Thanks again for your response!



Doughty, Michael wrote:
> 
> In the axis2.xml file on the server/service side, you should see this
> line:
> 
>     <parameter name="sendStacktraceDetailsWithFaults">false</parameter>
> 
> Set that parameter to "true".
> 
> Additionally, you might want to change this parameter as well:
> 
> <parameter name="DrillDownToRootCauseForFaultReason">false</parameter>
> 
> Setting that to "true" should force more stack trace detail to be sent
> along with it, including the details of the root cause exception.
> 
> -----Original Message-----
> From: glopezm [mailto:gmlopez.mackin...@gmail.com] 
> Sent: Monday, February 15, 2010 8:32 PM
> To: axis-user@ws.apache.org
> Subject: Axis2-1.5.1 and user exceptions
> 
> 
> Hi, 
> I'm using axis2 v1.5.1 as it is stated in the subject of this message and
> I've found that user exceptions are not being reported as they used to be
> with axis1. If one declare an operation throwing an exception, whenever
> the
> exception is thrown the detail part of the soap fault element used to be
> populated by axis1 with all exception data. However it is not working (at
> least in this way) anymore. The <soapenv:Detail /> tag is empty. There is
> a
> bug that was filed almost two years ago
> (https://issues.apache.org/jira/browse/AXIS2-3443) which explains the
> situation very clearly but it has not even been assigned yet!
> 
> Now I'm wondering whether someone is aware of a workaround to overcome
> this
> issue since it does not happen that the bug will be corrected anytime soon
> :-(.
> 
> Thanks in advance for your help!
> -- 
> View this message in context:
> http://old.nabble.com/Axis2-1.5.1-and-user-exceptions-tp27602949p27602949.html
> Sent from the Axis - User mailing list archive at Nabble.com.
> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Axis2-1.5.1-and-user-exceptions-tp27602949p27603868.html
Sent from the Axis - User mailing list archive at Nabble.com.

Reply via email to