microsoft.exchange.webservices.data.core.request
Class ServiceRequestBase<T>

java.lang.Object
  extended by microsoft.exchange.webservices.data.core.request.ServiceRequestBase<T>
Direct Known Subclasses:
HangingServiceRequestBase, SimpleServiceRequestBase

public abstract class ServiceRequestBase<T>
extends Object

Represents an abstract service request.


Constructor Summary
protected ServiceRequestBase(ExchangeService service)
          Initializes a new instance.
 
Method Summary
protected  HttpWebRequest buildEwsHttpPoolingWebRequest()
          Builds a HttpWebRequest object from a pooling connection manager for current service request with exception handling.
protected  HttpWebRequest buildEwsHttpWebRequest()
          Builds the HttpWebRequest object for current service request with exception handling.
protected  HttpWebRequest getEwsHttpWebResponse(HttpWebRequest request)
          Gets the IEwsHttpWebRequest object from the specifiedHttpWebRequest object with exception handling
protected abstract  ExchangeVersion getMinimumRequiredServerVersion()
          Gets the minimum server version required to process this request.
protected static InputStream getResponseStream(HttpWebRequest request)
          Gets the response stream (may be wrapped with GZip/Deflate stream to decompress content).
protected abstract  String getResponseXmlElementName()
          Gets the name of the response XML element.
 ExchangeService getService()
          Gets the service.
abstract  String getXmlElementName()
          Gets the name of the XML element.
protected abstract  T parseResponse(EwsServiceXmlReader reader)
          Parses the response.
protected  void processWebException(Exception webException, HttpWebRequest req)
          Processes the web exception.
protected  void readPreamble(EwsServiceXmlReader ewsXmlReader)
          Reads any preamble data not part of the core response.
protected  T readResponse(EwsServiceXmlReader ewsXmlReader)
          Reads the response.
protected  T readResponse(HttpWebRequest response)
          Reads the response.
protected  SoapFaultDetails readSoapFault(EwsServiceXmlReader reader)
          Reads the SOAP fault.
protected  void throwIfNotSupportedByRequestedServerVersion()
          Throw exception if request is not supported in requested server version.
protected  void traceResponse(HttpWebRequest request, ByteArrayOutputStream memoryStream)
          Traces the response.
protected  void validate()
          Validate request.
protected  HttpWebRequest validateAndEmitRequest()
          Validates request parameters, and emits the request to the server.
protected  void writeAttributesToXml(EwsServiceXmlWriter writer)
          Writes XML attribute.
protected  void writeBodyToXml(EwsServiceXmlWriter writer)
          Writes XML body.
protected abstract  void writeElementsToXml(EwsServiceXmlWriter writer)
          Writes XML elements.
protected  void writeToXml(EwsServiceXmlWriter writer)
          Writes XML.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceRequestBase

protected ServiceRequestBase(ExchangeService service)
                      throws ServiceVersionException
Initializes a new instance.

Parameters:
service - The service.
Throws:
ServiceVersionException - the service version exception
Method Detail

getXmlElementName

public abstract String getXmlElementName()
Gets the name of the XML element.

Returns:
XML element name

getResponseXmlElementName

protected abstract String getResponseXmlElementName()
Gets the name of the response XML element.

Returns:
XML element name

getMinimumRequiredServerVersion

protected abstract ExchangeVersion getMinimumRequiredServerVersion()
Gets the minimum server version required to process this request.

Returns:
Exchange server version.

parseResponse

protected abstract T parseResponse(EwsServiceXmlReader reader)
                            throws Exception
Parses the response.

Parameters:
reader - The reader.
Returns:
the Response Object.
Throws:
Exception - the exception

writeElementsToXml

protected abstract void writeElementsToXml(EwsServiceXmlWriter writer)
                                    throws Exception
Writes XML elements.

Parameters:
writer - The writer.
Throws:
Exception - the exception

validate

protected void validate()
                 throws Exception
Validate request.

Throws:
ServiceLocalException - the service local exception
Exception - the exception

writeBodyToXml

protected void writeBodyToXml(EwsServiceXmlWriter writer)
                       throws Exception
Writes XML body.

Parameters:
writer - The writer.
Throws:
Exception - the exception

writeAttributesToXml

protected void writeAttributesToXml(EwsServiceXmlWriter writer)
                             throws ServiceXmlSerializationException
Writes XML attribute. Subclass will override if it has XML attribute.

Parameters:
writer - The writer.
Throws:
ServiceXmlSerializationException - the service xml serialization exception

getService

public ExchangeService getService()
Gets the service.

Returns:
The service.

throwIfNotSupportedByRequestedServerVersion

protected void throwIfNotSupportedByRequestedServerVersion()
                                                    throws ServiceVersionException
Throw exception if request is not supported in requested server version.

Throws:
ServiceVersionException - the service version exception

writeToXml

protected void writeToXml(EwsServiceXmlWriter writer)
                   throws Exception
Writes XML.

Parameters:
writer - The writer.
Throws:
Exception - the exception

getResponseStream

protected static InputStream getResponseStream(HttpWebRequest request)
                                        throws IOException,
                                               EWSHttpException
Gets the response stream (may be wrapped with GZip/Deflate stream to decompress content).

Parameters:
request - HttpWebRequest object from which response stream can be read.
Returns:
ResponseStream
Throws:
IOException - Signals that an I/O exception has occurred.
EWSHttpException - the EWS http exception

traceResponse

protected void traceResponse(HttpWebRequest request,
                             ByteArrayOutputStream memoryStream)
                      throws XMLStreamException,
                             IOException,
                             EWSHttpException
Traces the response.

Parameters:
request - the response
memoryStream - the response content in a MemoryStream
Throws:
XMLStreamException - the XML stream exception
IOException - signals that an I/O exception has occurred
EWSHttpException - the EWS http exception

readResponse

protected T readResponse(HttpWebRequest response)
                  throws Exception
Reads the response.

Parameters:
response - HTTP web request
Returns:
response response object
Throws:
Exception - on error

readResponse

protected T readResponse(EwsServiceXmlReader ewsXmlReader)
                  throws Exception
Reads the response.

Parameters:
ewsXmlReader - The XML reader.
Returns:
Service response.
Throws:
Exception - the exception

readPreamble

protected void readPreamble(EwsServiceXmlReader ewsXmlReader)
                     throws Exception
Reads any preamble data not part of the core response.

Parameters:
ewsXmlReader - The EwsServiceXmlReader.
Throws:
Exception - on error

processWebException

protected void processWebException(Exception webException,
                                   HttpWebRequest req)
                            throws Exception
Processes the web exception.

Parameters:
webException - the web exception
req - HTTP Request object used to send the http request
Throws:
Exception - on error

readSoapFault

protected SoapFaultDetails readSoapFault(EwsServiceXmlReader reader)
Reads the SOAP fault.

Parameters:
reader - The reader.
Returns:
SOAP fault details.

validateAndEmitRequest

protected HttpWebRequest validateAndEmitRequest()
                                         throws Exception
Validates request parameters, and emits the request to the server.

Returns:
The response returned by the server.
Throws:
Exception - on error

buildEwsHttpWebRequest

protected HttpWebRequest buildEwsHttpWebRequest()
                                         throws Exception
Builds the HttpWebRequest object for current service request with exception handling.

Returns:
An HttpWebRequest instance
Throws:
Exception - on error

buildEwsHttpPoolingWebRequest

protected HttpWebRequest buildEwsHttpPoolingWebRequest()
                                                throws Exception
Builds a HttpWebRequest object from a pooling connection manager for current service request with exception handling.

Used for subscriptions.

Returns:
A HttpWebRequest instance
Throws:
Exception - on error

getEwsHttpWebResponse

protected HttpWebRequest getEwsHttpWebResponse(HttpWebRequest request)
                                        throws Exception
Gets the IEwsHttpWebRequest object from the specifiedHttpWebRequest object with exception handling

Parameters:
request - The specified HttpWebRequest
Returns:
An HttpWebResponse instance
Throws:
Exception - on error


Copyright © 2012–2015 Microsoft. All rights reserved.