Class ServiceRequestBase<T>
- java.lang.Object
-
- 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
Constructors Modifier Constructor Description protectedServiceRequestBase(ExchangeService service)Initializes a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected HttpWebRequestbuildEwsHttpPoolingWebRequest()Builds a HttpWebRequest object from a pooling connection manager for current service request with exception handling.protected HttpWebRequestbuildEwsHttpWebRequest()Builds the HttpWebRequest object for current service request with exception handling.protected HttpWebRequestgetEwsHttpWebResponse(HttpWebRequest request)Gets the IEwsHttpWebRequest object from the specifiedHttpWebRequest object with exception handlingprotected abstract ExchangeVersiongetMinimumRequiredServerVersion()Gets the minimum server version required to process this request.protected static InputStreamgetResponseStream(HttpWebRequest request)Gets the response stream (may be wrapped with GZip/Deflate stream to decompress content).protected abstract StringgetResponseXmlElementName()Gets the name of the response XML element.ExchangeServicegetService()Gets the service.abstract StringgetXmlElementName()Gets the name of the XML element.protected abstract TparseResponse(EwsServiceXmlReader reader)Parses the response.protected voidprocessWebException(Exception webException, HttpWebRequest req)Processes the web exception.protected voidreadPreamble(EwsServiceXmlReader ewsXmlReader)Reads any preamble data not part of the core response.protected TreadResponse(EwsServiceXmlReader ewsXmlReader)Reads the response.protected TreadResponse(HttpWebRequest response)Reads the response.protected SoapFaultDetailsreadSoapFault(EwsServiceXmlReader reader)Reads the SOAP fault.protected voidthrowIfNotSupportedByRequestedServerVersion()Throw exception if request is not supported in requested server version.protected voidtraceResponse(HttpWebRequest request, ByteArrayOutputStream memoryStream)Traces the response.protected voidvalidate()Validate request.protected HttpWebRequestvalidateAndEmitRequest()Validates request parameters, and emits the request to the server.protected voidwriteAttributesToXml(EwsServiceXmlWriter writer)Writes XML attribute.protected voidwriteBodyToXml(EwsServiceXmlWriter writer)Writes XML body.protected abstract voidwriteElementsToXml(EwsServiceXmlWriter writer)Writes XML elements.protected voidwriteToXml(EwsServiceXmlWriter writer)Writes XML.
-
-
-
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 exceptionException- 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 responsememoryStream- the response content in a MemoryStream- Throws:
XMLStreamException- the XML stream exceptionIOException- signals that an I/O exception has occurredEWSHttpException- 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 exceptionreq- 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
-
-