|
soap tutorial | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectadriani.jws.template.util.SoapHandler
public class SoapHandler
This class is used by the XXXMessageReceiverInOut
handler to acknowledge data stored in
the SOAP's header. Access to this class should be inserted in the XXXMessageReceiverInOut
source file, right after the
if("my_method".equals(methodName)) {
statement. The suggested usage is:
adriani.jws.template.util.SoapElements elements = adriani.jws.template.util.SoapHandler.getElements(msgContext) ;
org.apache.axiom.om.OMElement first_element = elements.getFirstElement() ;
String header_value = elements.getHeaderData() ;
skel.setHeaderField(header_value) ;
manage()
method and the getParsingError()
method.getParsingError()
method should be invoked within a skeleton
class, as produced by the wsdl2java tool. The method should be called in the catch()
section at the end of the parse()
method, right after thecatch (javax.xml.stream.XMLStreamException e)
catch (java.lang.Exception e) {
// Keep for testing or debug
//adriani.jws.template.util.ParsingHandler.analyzeThrowable(e) ;
String msg = adriani.jws.template.util.ParsingHandler.getParsingError(MY_QNAME, reader, e) ;
throw new java.lang.Exception(msg, e) ;
}
manage()
method should be invoked only by the class
XXXMessageReceiverInOut
. The method should be called in the catch()
section at the end of the invokeBusinessLogic()
method, by substituting the original
exception management, which should be something likethrow org.apache.axis2.AxisFault.makeFault(e)
catch (java.lang.Exception e) {
org.apache.axiom.soap.SOAPFactory factory = getSOAPFactory(msgContext) ;
org.apache.axiom.soap.SOAPEnvelope envelope = adriani.jws.template.util.ParsingHandler.manage(msgContext, factory) ;
newMsgContext.setEnvelope(envelope) ;
}
Field Summary | |
---|---|
static java.lang.String |
BLANK
Static final String value stored as class fields to improve performances. |
static java.lang.String |
COLON
Static final String value stored as class fields to improve performances. |
static java.lang.String |
EMPTY
Static final String value stored as class fields to improve performances. |
static java.lang.String |
GET_INFORMATION
Static final String value stored as class fields to improve performances. |
protected static java.lang.String |
leadingName
Beginning of each logging message produced by this class. |
protected static WSLogger |
logger
Retrieving the logger instance to be used for this class. |
static java.lang.String |
MANAGE
Static final String value stored as class fields to improve performances. |
static java.util.regex.Pattern |
pattern
Static final Pattern object stored as class field to improve performances. |
static java.lang.String |
RET
Static final String value stored as class fields to improve performances. |
static java.lang.String |
TAB
Static final String value stored as class fields to improve performances. |
static java.lang.String |
UNKNOWN
Static final String value stored as class fields to improve performances. |
Constructor Summary | |
---|---|
SoapHandler()
|
Method Summary | |
---|---|
static void |
analyzeAxisFault(java.lang.Throwable cause)
NOT USED AT THE MOMENT! |
static java.lang.StringBuffer |
analyzeThrowable(java.lang.Throwable cause)
Produce some logging information about a general Throwable object. |
static java.lang.StringBuffer |
getElementInfo(java.lang.StackTraceElement element)
Return some information (already formatted) about the input StackTraceElement instance. |
static SoapElements |
getElements(MessageContext msgContext)
Retrieves the OMElement representing the SOAP's body and the SOAP's header,
fetching them from the MessageContext Axis2's handler. |
static java.lang.String |
getEventType(int id)
Recognize the integer code describing the XML element pointed by a XMLStreamReader
instance and return a string message describing the XML element (or event) type. |
static java.lang.StackTraceElement |
getFirstElement(java.lang.Throwable cause)
Return the first StackTraceElement instance from the stack trace element bound to
the input Throwable object. |
static java.lang.StringBuffer |
getFirstElementInfo(java.lang.Throwable cause)
Return some information (already formatted) about the first StackTraceElement of the
the input Throwable stack array. |
static java.lang.String |
getParsingError(javax.xml.namespace.QName qName,
javax.xml.stream.XMLStreamReader reader,
java.lang.Throwable cause)
Get detailed information about the XML validation failure from the Axis2 stream reader, in this case a XMLStreamReader object, then uses these information to log a proper ERROR message in the
log system and to produce the string message describing the error. |
static java.lang.String |
getSOAPMethod(javax.xml.namespace.QName qName)
Return the local part of the input ADBBean object that generates the parsing error. |
static SOAPEnvelope |
manage(MessageContext msgContext,
SOAPFactory factory)
Identifies the current SOAP operation (the SOAP method) in order to choose the proper output wrapper to be used to produce the SOAP envelope. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.util.regex.Pattern pattern
Pattern
object stored as class field to improve performances.
public static final java.lang.String RET
String
value stored as class fields to improve performances.
public static final java.lang.String TAB
String
value stored as class fields to improve performances.
public static final java.lang.String COLON
String
value stored as class fields to improve performances.
public static final java.lang.String EMPTY
String
value stored as class fields to improve performances.
public static final java.lang.String BLANK
String
value stored as class fields to improve performances.
public static final java.lang.String UNKNOWN
String
value stored as class fields to improve performances.
public static final java.lang.String MANAGE
String
value stored as class fields to improve performances.
public static final java.lang.String GET_INFORMATION
String
value stored as class fields to improve performances.
protected static WSLogger logger
protected static final java.lang.String leadingName
Constructor Detail |
---|
public SoapHandler()
Method Detail |
---|
public static SoapElements getElements(MessageContext msgContext)
OMElement
representing the SOAP's body and the SOAP's header,
fetching them from the MessageContext
Axis2's handler. This MUST BE done
before invoking others "Axis2 stuff" because the MessageContext
has a very
short live and cannot be parsed twice.interface org.apache.axiom.soap.SOAPHeader
interface org.apache.axiom.soap.SOAPBody
msgContext
- the input message context used to invoke the business logic
SoapElements
wrapper containing all envelope's elements
AxisFault
- if an ADBException
occurs while producing the SOAP envelopepublic static SOAPEnvelope manage(MessageContext msgContext, SOAPFactory factory) throws AxisFault
SOAPEnvelope
object that can be set on the newMsgContext
instance.
For the time being this method relies only of one wrapper: the WrapperSearchOut
.wrapper.getElement()
method, in order
to get the proper ADBBean
instance to be added the the SOAP envelope's body.
msgContext
- the input message context used to invoke the business logicfactory
- a SOAP factory retrieved using getSOAPFactory(msgContext)
newMsgContext
object
AxisFault
- if an ADBException
occurs while producing the SOAP envelopepublic static java.lang.String getParsingError(javax.xml.namespace.QName qName, javax.xml.stream.XMLStreamReader reader, java.lang.Throwable cause)
XMLStreamReader
object, then uses these information to log a proper ERROR message in the
log system and to produce the string message describing the error. The string message could be used
to set the SOAP response: this is not necessary at the moment, since the error management
is completely performed by the manage()
method.verbose
flag is true
some detailed information about the
XMLStreamReader
object are also logged using the INFO logger label.
qName
- the qualified name of the input ADBBean
who generates the errorreader
- the XMLStreamReader
used to parse the SOAP requestcause
- an instance of a general Throwable
object
ErrorMessage
classpublic static java.lang.String getSOAPMethod(javax.xml.namespace.QName qName)
ADBBean
object that generates the parsing error.
qName
- the qualified name of an ADBBean
instance
ADBBean
instancepublic static java.lang.String getEventType(int id)
XMLStreamReader
instance and return a string message describing the XML element (or event) type. The mapping
between integers and string messages is retrieved from the constants defined in the
javax.xml.stream.XMLStreamConstants
class.
id
- the integer number retrieved from the reader.getEventType()
method
public static java.lang.StackTraceElement getFirstElement(java.lang.Throwable cause)
StackTraceElement
instance from the stack trace element bound to
the input Throwable
object.
cause
- an instance of a general Throwable
object
StackTraceElement
instancepublic static java.lang.StringBuffer getFirstElementInfo(java.lang.Throwable cause)
StackTraceElement
of the
the input Throwable
stack array. These information are retrieved by invoking the
getElementInfo()
method.
cause
- an instance of a general Throwable
object
public static java.lang.StringBuffer getElementInfo(java.lang.StackTraceElement element)
StackTraceElement
instance.
element
- a valid StackTraceElement
instance
public static java.lang.StringBuffer analyzeThrowable(java.lang.Throwable cause)
Throwable
object.fromOM()
of the message receiver class
(in this case a XXXMessageReceiverInOut
instance) in order to obtain information about the
general Exception
used to invoke the org.apache.axis2.AxisFault.makeFault(e)
method. Example:
catch (java.lang.Exception e) {
//adriani.jws.template.util.ParsingHandler.analyzeThrowable(e) ; // Keep for testing or debug
throw org.apache.axis2.AxisFault.makeFault(e) ; // Original code
//throw adriani.jws.template.util.ParsingException.makeFault(e) ; // Modified code
}
cause
- an instance of a general Throwable
object
public static void analyzeAxisFault(java.lang.Throwable cause)
AxisFault
exception when parsing the SOAP request, neither
when invoking the skeleton business logic. The AxisFault
faults are created only
by the XXXMessageReceiverInOut
handler class, after "the point" where we want to
insert the management of general parsing errors (and the "too late").
cause
- an instance of a general Throwable
object
|
Build 19/03/2014 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |