soap tutorial

adriani.jws.template.wrappers
Class WrapperOut

java.lang.Object
  extended by adriani.jws.template.wrappers.Wrapper
      extended by adriani.jws.template.wrappers.WrapperOut
Direct Known Subclasses:
WrapperDateOut, WrapperInformationOut

public abstract class WrapperOut
extends Wrapper

WrapperOut - general class wrapping the root ADBBean element containing a general output result. This class should be the general parent class for all output wrappers.

This class can wrap an actual array of Wrapper objects, a single Wrapper object or none other wrapper (if the SOAP response does not contain any nested structure). In this way if the WSDL specifications changed the whole architecture should not change: to change from an array-oriented response to a simple plain response just change the implementation the validate() method.


Field Summary
protected  java.lang.StringBuffer details
          The text message describing the status of the response.
protected static java.lang.String leadingName
          Beginning of each logging message produced by this class.
protected  java.lang.StringBuffer message
          The text message describing the status of the response.
static java.lang.StringBuffer MESSAGE_NOK
          Static reference values for the MESSAGE field.
static java.lang.StringBuffer MESSAGE_OK
          Static reference values for the MESSAGE field.
static java.lang.StringBuffer MESSAGE_UNSET
          Static reference values for the MESSAGE field.
static java.lang.StringBuffer MESSAGE_WRONG
          Static reference values for the MESSAGE field.
static java.lang.StringBuffer NO_DETAILS
          Static reference values for the VERBOSE field.
protected  Wrapper[] records
          The array of the "inner wrappers" stored as CLASS FIELD before validation.
protected  int status
          The integer code describing the status of the response.
static int STATUS_OK
          Static reference value for the STATUS field.
static int STATUS_UNSET
          Static reference value for the STATUS field.
static int STATUS_WRONG
          Static reference value for the STATUS field.
 
Fields inherited from class adriani.jws.template.wrappers.Wrapper
element, logger, NO_NUMBER, NOT_AVAILABLE, NOT_BIG_INTEGER, UNDEFINED
 
Constructor Summary
WrapperOut()
          Stateless constructor, loading the default values into this wrapper.
WrapperOut(Wrapper[] array)
          Stateful constructor, creating an WrapperSearch set with the input array.
 
Method Summary
abstract  void forceMessage(java.lang.String message)
          Set a string message in the inner ADBBean element, without checking for validation and overwriting the previous value of the message class attribute (if any).
abstract  void forceStatus(int value)
          Set an integer value in the wrapped ADBBean element, without checking for validation and ignoring the value of the status class attribute.
 java.lang.StringBuffer getDetails()
          Return the detailed text message wrapped by this class.
 java.lang.StringBuffer getMessage()
          Return the value of the text message wrapped by this class.
 Wrapper[] getRecords()
          Return the array of Wrapper records wrapped by this class.
 int getStatus()
          Return the value of the status flag wrapped by this class.
 void reset()
          Cleans the inner wrapper (or the inner array of wrappers), by resetting all fields to their minimal value.
 void setDefaults()
          Load all the STATIC default values (defined in this class) into the corresponding class attributes.
 void setDetails(java.lang.StringBuffer value)
          Set the detailed text message wrapped by this class.
 void setMessage(java.lang.StringBuffer value)
          Set the value of the text message wrapped by this class.
 void setRecords(Wrapper[] value)
          Set the array of Wrapper records wrapped by this class.
 void setStatus(int value)
          Set the value of the status flag wrapped by this class.
 
Methods inherited from class adriani.jws.template.wrappers.Wrapper
compareSB, getElement, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

records

protected Wrapper[] records
The array of the "inner wrappers" stored as CLASS FIELD before validation.


status

protected int status
The integer code describing the status of the response.


message

protected java.lang.StringBuffer message
The text message describing the status of the response.


details

protected java.lang.StringBuffer details
The text message describing the status of the response.


STATUS_OK

public static int STATUS_OK
Static reference value for the STATUS field.


STATUS_WRONG

public static int STATUS_WRONG
Static reference value for the STATUS field.


STATUS_UNSET

public static int STATUS_UNSET
Static reference value for the STATUS field.


MESSAGE_OK

public static java.lang.StringBuffer MESSAGE_OK
Static reference values for the MESSAGE field.


MESSAGE_NOK

public static java.lang.StringBuffer MESSAGE_NOK
Static reference values for the MESSAGE field.


MESSAGE_WRONG

public static java.lang.StringBuffer MESSAGE_WRONG
Static reference values for the MESSAGE field.


MESSAGE_UNSET

public static java.lang.StringBuffer MESSAGE_UNSET
Static reference values for the MESSAGE field.


NO_DETAILS

public static java.lang.StringBuffer NO_DETAILS
Static reference values for the VERBOSE field.


leadingName

protected static java.lang.String leadingName
Beginning of each logging message produced by this class.

Constructor Detail

WrapperOut

public WrapperOut()
Stateless constructor, loading the default values into this wrapper. This means the all the class attributes are defined, but no ADBBean element is instantiated, because we delegate this task to the validate() method, in order to grant loose coupling.

See Also:
setDefaults()

WrapperOut

public WrapperOut(Wrapper[] array)
Stateful constructor, creating an WrapperSearch set with the input array.
Remark: this method MUST NOT set the defaults values, since for this service we don't want to return any message if everything goes fine

Parameters:
array - the array of WrapperSearch[]
Method Detail

setDefaults

public void setDefaults()
Load all the STATIC default values (defined in this class) into the corresponding class attributes. This method should also populate the records array of Wrapper objects as expected by the default empty response.

Example: if the empty SOAP response should contain just one single Wrapper object, this method should create an array with just one record.

Hint: subclasses should call this method inside the constructor.

Specified by:
setDefaults in class Wrapper
See Also:
Wrapper, forceMessage(String message)

forceStatus

public abstract void forceStatus(int value)
Set an integer value in the wrapped ADBBean element, without checking for validation and ignoring the value of the status class attribute. This method is used when validation fails and it's necessary to set the response status in the status field of the wrapped ADBBean element.

Parameters:
value - the response status value

forceMessage

public abstract void forceMessage(java.lang.String message)
Set a string message in the inner ADBBean element, without checking for validation and overwriting the previous value of the message class attribute (if any). This method is used when validation fails and it's necessary to communicate the error in a message field of the wrapped ADBBean element (usually the message field).

Remark: this method MUST be called only after validation, because we want to put all the building logic of the ADBBean structure in the validate() method.

Parameters:
message - the error message that must be set in the proper message field of the response

reset

public void reset()
Cleans the inner wrapper (or the inner array of wrappers), by resetting all fields to their minimal value. This method should be called when the response is wrong or failed, and we want to avoid to return some incomplete (but correct) data to the client.

This method MUST BE called before validation, since it affects the wrapper's class fields and not the ADBBean elements.


getStatus

public int getStatus()
Return the value of the status flag wrapped by this class.
Default implementation uses 1 for a good valid SOAP response, 0 elsewhere. Subclasses can change this definitions by overriding the static STATUS_XXX fields.

Returns:
the integer status flag (the wrapper's class field)

getMessage

public java.lang.StringBuffer getMessage()
Return the value of the text message wrapped by this class.
The message specifies the type of the SOAP response described by the status flag. Subclasses can change this definitions by overriding the static MESSAGE_XXX fields.

Returns:
the text status message (the wrapper's class field)

getDetails

public java.lang.StringBuffer getDetails()
Return the detailed text message wrapped by this class.
This field adds details to the message text.

Returns:
the detailed text status message (the wrapper's class field)

getRecords

public Wrapper[] getRecords()
Return the array of Wrapper records wrapped by this class.
It the web service returns just a single Wrapper object, this should be stored into the records[0] element.

Returns:
the array of Wrapper records (the wrapper's class field)

setStatus

public void setStatus(int value)
Set the value of the status flag wrapped by this class.
Default implementation uses 1 for a good valid SOAP response, 0 elsewhere. Subclasses can change this definitions by overriding the static STATUS_XXX fields.

Parameters:
value - the integer status flag (will be stored as class field)

setMessage

public void setMessage(java.lang.StringBuffer value)
Set the value of the text message wrapped by this class.
The message details the quality of the SOAP response described by the status flag. Subclasses can change this definitions by overriding the static MESSAGE_XXX fields.

Parameters:
value - the text status message (will be stored as class field)

setDetails

public void setDetails(java.lang.StringBuffer value)
Set the detailed text message wrapped by this class.
This field adds details to the message text.

Parameters:
value - the detailed text status message (the wrapper's class field)

setRecords

public void setRecords(Wrapper[] value)
Set the array of Wrapper records wrapped by this class.
It the web service returns just a single Wrapper object, this should be stored into the records[0] element.

Parameters:
value - the array of Wrapper records ((will be stored as class field)

Build 19/03/2014

Morpheus Technologies - making the Zion software
Copyright © 2009-2014 Morpheus Technologies. All Rights Reserved