soaprest
Class ResponseUtility

java.lang.Object
  extended by soaprest.ResponseUtility

@Copyright
public class ResponseUtility
extends java.lang.Object

Utility for constructing the web service responses, including both normal return values and exceptions. The exceptions are fault exceptions. A SOAP client will handle these by converting them to exceptions. A REST client has no such capability. One can either return a generic HTTP code with no information about what failed, or one can return the body of a SOAP fault exception.


Field Summary
private  javax.xml.parsers.DocumentBuilder builder
          The DOM document builder.
private  javax.xml.bind.JAXBContext context
          JAXB Serialization Context.
private  InvocationUtility invoker
          The invocation utility.
 
Constructor Summary
ResponseUtility(java.lang.String packages, InvocationUtility invoker)
          Construct a response utility.
 
Method Summary
 void response(org.w3c.dom.Document doc, javax.servlet.http.HttpServletResponse res)
          DOM document formatting.
 void response(org.w3c.dom.Document doc, java.io.OutputStream out)
          DOM document formatting.
 javax.xml.transform.Source response(SoapRestException exception)
          Fault formatting.
 void response(SoapRestException exception, javax.servlet.http.HttpServletResponse res)
          Fault formatting.
 void response(SoapRestException exception, java.io.OutputStream out)
          Fault formatting.
 javax.xml.transform.Source response(SoapRestObject soaprestObject)
          Object response formatting to a source.
 void response(SoapRestObject soaprestObject, javax.servlet.http.HttpServletResponse res)
          Object response formatting.
 void response(SoapRestObject soaprestObject, java.io.OutputStream out)
          Object response formatting.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

private javax.xml.bind.JAXBContext context
JAXB Serialization Context.


builder

private javax.xml.parsers.DocumentBuilder builder
The DOM document builder.


invoker

private InvocationUtility invoker
The invocation utility.

Constructor Detail

ResponseUtility

public ResponseUtility(java.lang.String packages,
                       InvocationUtility invoker)
                throws java.lang.Exception
Construct a response utility.

Parameters:
packages - The colon-delimited list of packages with serializable classes.
invoker - The invocation utility.
Throws:
java.lang.Exception - if an object factory is not available for a specified package.
Method Detail

response

public void response(SoapRestObject soaprestObject,
                     javax.servlet.http.HttpServletResponse res)
              throws SoapRestException
Object response formatting.

Parameters:
soaprestObject - The value of the response element. While the soaprestObject itself is never null, it can contain a null object.
res - The HttpServletResponse object that contains the response to the client.
Throws:
SoapRestException - if a transformation error occurred.

response

public void response(SoapRestObject soaprestObject,
                     java.io.OutputStream out)
              throws SoapRestException
Object response formatting.

Parameters:
soaprestObject - The value of the response element. While the soaprestObject itself is never null, it can contain a null object.
out - The output stream to which the object is to be written.
Throws:
SoapRestException - if a transformation error occurred.

response

public javax.xml.transform.Source response(SoapRestObject soaprestObject)
                                    throws SoapRestException
Object response formatting to a source.

Parameters:
soaprestObject - The value of the response element. While the soaprestObject itself is never null, it can contain a null object.
Returns:
The formatted response as a source.
Throws:
SoapRestException - if an object factory is not available for a specified package.

response

public void response(SoapRestException exception,
                     javax.servlet.http.HttpServletResponse res)
              throws SoapRestException
Fault formatting.

Parameters:
exception - The exception to be formatted.
res - The HttpServletResponse object that contains the response to the client.
Throws:
SoapRestException - if the transformation failed.

response

public void response(SoapRestException exception,
                     java.io.OutputStream out)
              throws SoapRestException
Fault formatting.

Parameters:
exception - The exception to be formatted.
out - The output stream to which the exception is to be written.
Throws:
SoapRestException - if the transformation failed.

response

public javax.xml.transform.Source response(SoapRestException exception)
Fault formatting.

Parameters:
exception - The exception to be formatted.
Returns:
The formatted exception as a source.

response

public void response(org.w3c.dom.Document doc,
                     javax.servlet.http.HttpServletResponse res)
DOM document formatting. Exceptions are ignored.

Parameters:
doc - The document.
res - The HttpServletResponse object that contains the response to the client.

response

public void response(org.w3c.dom.Document doc,
                     java.io.OutputStream out)
DOM document formatting. Exceptions are ignored.

Parameters:
doc - The document.
out - The output stream to which the object is to be written.