microsoft.exchange.webservices.data
Class ExchangeServiceBase

java.lang.Object
  extended by microsoft.exchange.webservices.data.ExchangeServiceBase
Direct Known Subclasses:
AutodiscoverService, ExchangeService

public abstract class ExchangeServiceBase
extends java.lang.Object

Represents an abstract binding to an Exchange Service.


Constructor Summary
protected ExchangeServiceBase()
           
protected ExchangeServiceBase(ExchangeServiceBase service)
          Initializes a new instance from existing one.
protected ExchangeServiceBase(ExchangeServiceBase service, ExchangeVersion requestedServerVersion)
           
protected ExchangeServiceBase(ExchangeVersion requestedServerVersion)
          * Initializes a new instance.
protected ExchangeServiceBase(ExchangeVersion requestedServerVersion, java.util.TimeZone timeZone)
           
protected ExchangeServiceBase(java.util.TimeZone timeZone)
           
 
Method Summary
static boolean checkURIPath(java.lang.String location)
           
protected  java.lang.String convertDateTimeToUniversalDateTimeString(java.util.Date dt)
          Converts the date time to universal date time string.
protected  java.util.Date convertStartDateToUnspecifiedDateTime(java.lang.String value)
          Converts xs:dateTime string with either "Z", "-00:00" bias, or "" suffixes to unspecified StartDate value ignoring the suffix.Needs to fix E14:232996.
protected  java.util.Date convertUniversalDateTimeStringToDate(java.lang.String dateString)
          Converts the universal date time string to local date time.
protected  void doOnSerializeCustomSoapHeaders(javax.xml.stream.XMLStreamWriter writer)
          Calls the custom SOAP header serialisation event handlers, if defined.
 boolean getAcceptGzipEncoding()
          Gets a value indicating whether GZip compression encoding should be accepted.
 java.lang.String getCookie(java.net.URL url)
          Gets the cookie.
 ExchangeCredentials getCredentials()
          Gets the credentials used to authenticate with the Exchange Web Services.
 java.util.Map<java.lang.String,java.lang.String> getHttpHeaders()
          Gets a collection of HTTP headers that will be sent with each request to EWS.
 java.util.Map<java.lang.String,java.lang.String> getHttpResponseHeaders()
          Gets a collection of HTTP headers from the last response.
 java.util.List<microsoft.exchange.webservices.data.ICustomXmlSerialization> getOnSerializeCustomSoapHeaders()
          Gets the on serialize custom soap headers.
 ExchangeVersion getRequestedServerVersion()
          Gets the requested server version.
 ExchangeServerInfo getServerInfo()
          * Gets information associated with the server that processed the last request.
protected static byte[] getSessionKey()
          Gets the session key.
protected  org.apache.commons.httpclient.HttpConnectionManager getSimpleHttpConnectionManager()
          Static members
 int getTimeout()
          Gets the timeout used when sending HTTP requests and when receiving HTTP responses, in milliseconds.
 java.util.EnumSet<TraceFlags> getTraceFlags()
          Gets the trace flags.
 ITraceListener getTraceListener()
          Gets the trace listener.
 boolean getUseDefaultCredentials()
          Gets a value indicating whether the credentials of the user currently logged into Windows should be used to authenticate with the Exchange Web Services.
 java.lang.String getUserAgent()
          Gets the user agent.
 WebProxy getWebProxy()
          Gets the web proxy that should be used when sending requests to EWS.
protected  void internalProcessHttpErrorResponse(microsoft.exchange.webservices.data.HttpWebRequest httpWebResponse, java.lang.Exception webException, TraceFlags responseHeadersTraceFlag, TraceFlags responseTraceFlag)
          This method doesn't handle 500 ISE errors.
 boolean isPreAuthenticate()
          Gets a value that indicates whether HTTP pre-authentication should be performed.
 boolean isTraceEnabled()
          Gets a value indicating whether tracing is enabled.
protected  boolean isTraceEnabledFor(TraceFlags traceFlags)
          Determines whether tracing is enabled for specified trace flag(s).
protected  microsoft.exchange.webservices.data.HttpWebRequest prepareHttpWebRequestForUrl(java.net.URI url, boolean acceptGzipEncoding, boolean allowAutoRedirect)
          * Creates an HttpWebRequest instance and initialises it with the appropriate parameters, based on the configuration of this service object.
protected abstract  void processHttpErrorResponse(microsoft.exchange.webservices.data.HttpWebRequest httpWebResponse, java.lang.Exception webException)
           
protected  void processHttpResponseHeaders(TraceFlags traceType, microsoft.exchange.webservices.data.HttpWebRequest request)
          Traces the HTTP response headers.
 void setAcceptGzipEncoding(boolean acceptGzipEncoding)
          Gets a value indicating whether GZip compression encoding should be accepted.
 void setCookie(java.net.URL url, java.lang.String value)
          Gets the cookie container.
 void setCredentials(ExchangeCredentials credentials)
          Sets the credentials used to authenticate with the Exchange Web Services.
protected  void setCustomUserAgent(java.lang.String userAgent)
          Sets the user agent to a custom value
 void setOnSerializeCustomSoapHeaders(java.util.List<microsoft.exchange.webservices.data.ICustomXmlSerialization> onSerializeCustomSoapHeaders)
          Sets the on serialize custom soap headers.
 void setPreAuthenticate(boolean preAuthenticate)
          Sets a value that indicates whether HTTP pre-authentication should be performed.
 void setTimeout(int timeout)
          Sets the timeout used when sending HTTP requests and when receiving HTTP respones, in milliseconds.
 void setTraceEnabled(boolean traceEnabled)
          Sets a value indicating whether tracing is enabled.
 void setTraceFlags(java.util.EnumSet<TraceFlags> traceFlags)
          Sets the trace flags.
 void setTraceListener(ITraceListener traceListener)
          Sets the trace listener.
 void setUseDefaultCredentials(boolean value)
          * Sets a value indicating whether the credentials of the user currently logged into Windows should be used to authenticate with the Exchange Web Services.
 void setUserAgent(java.lang.String userAgent)
          Sets the user agent.
 void setWebProxy(WebProxy value)
          Sets the web proxy that should be used when sending requests to EWS.
protected  void traceHttpRequestHeaders(TraceFlags traceType, microsoft.exchange.webservices.data.HttpWebRequest request)
          Traces the HTTP request headers.
protected  void traceMessage(TraceFlags traceType, java.lang.String logEntry)
          * Logs the specified string to the TraceListener if tracing is enabled.
protected  void traceXml(TraceFlags traceType, java.io.ByteArrayOutputStream stream)
          Logs the specified XML to the TraceListener if tracing is enabled.
protected  void validate()
          * Validates this instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExchangeServiceBase

protected ExchangeServiceBase(ExchangeServiceBase service,
                              ExchangeVersion requestedServerVersion)
Parameters:
service -
requestedServerVersion -

ExchangeServiceBase

protected ExchangeServiceBase(ExchangeServiceBase service)
Initializes a new instance from existing one.

Parameters:
service - The other service.
See Also:
ExchangeServiceBase

ExchangeServiceBase

protected ExchangeServiceBase()

ExchangeServiceBase

protected ExchangeServiceBase(ExchangeVersion requestedServerVersion,
                              java.util.TimeZone timeZone)

ExchangeServiceBase

protected ExchangeServiceBase(java.util.TimeZone timeZone)

ExchangeServiceBase

protected ExchangeServiceBase(ExchangeVersion requestedServerVersion)
* Initializes a new instance.

Parameters:
requestedServerVersion - The requested server version.
Method Detail

getSimpleHttpConnectionManager

protected org.apache.commons.httpclient.HttpConnectionManager getSimpleHttpConnectionManager()
Static members


doOnSerializeCustomSoapHeaders

protected void doOnSerializeCustomSoapHeaders(javax.xml.stream.XMLStreamWriter writer)
Calls the custom SOAP header serialisation event handlers, if defined.

Parameters:
writer - The XmlWriter to which to write the custom SOAP headers.

prepareHttpWebRequestForUrl

protected microsoft.exchange.webservices.data.HttpWebRequest prepareHttpWebRequestForUrl(java.net.URI url,
                                                                                         boolean acceptGzipEncoding,
                                                                                         boolean allowAutoRedirect)
                                                                                  throws ServiceLocalException,
                                                                                         java.net.URISyntaxException
* Creates an HttpWebRequest instance and initialises it with the appropriate parameters, based on the configuration of this service object.

Parameters:
url - The URL that the HttpWebRequest should target.
acceptGzipEncoding - If true, ask server for GZip compressed content.
allowAutoRedirect - If true, redirection responses will be automatically followed.
Returns:
An initialised instance of HttpWebRequest.
Throws:
ServiceLocalException - the service local exception
java.net.URISyntaxException - the uRI syntax exception

internalProcessHttpErrorResponse

protected void internalProcessHttpErrorResponse(microsoft.exchange.webservices.data.HttpWebRequest httpWebResponse,
                                                java.lang.Exception webException,
                                                TraceFlags responseHeadersTraceFlag,
                                                TraceFlags responseTraceFlag)
                                         throws java.lang.Exception
This method doesn't handle 500 ISE errors. This is handled by the caller since 500 ISE typically indicates that a SOAP fault has occurred and the handling of a SOAP fault is currently service specific.

Parameters:
httpWebResponse -
webException -
responseHeadersTraceFlag -
responseTraceFlag -
Throws:
java.lang.Exception

checkURIPath

public static boolean checkURIPath(java.lang.String location)
Parameters:
location -
Returns:
false if location is null,true if this abstract pathname is absolute,

processHttpErrorResponse

protected abstract void processHttpErrorResponse(microsoft.exchange.webservices.data.HttpWebRequest httpWebResponse,
                                                 java.lang.Exception webException)
                                          throws java.lang.Exception
Parameters:
httpWebResponse -
webException -
Throws:
java.lang.Exception

isTraceEnabledFor

protected boolean isTraceEnabledFor(TraceFlags traceFlags)
Determines whether tracing is enabled for specified trace flag(s).

Parameters:
traceFlags - The trace flags.
Returns:
True if tracing is enabled for specified trace flag(s).

traceMessage

protected void traceMessage(TraceFlags traceType,
                            java.lang.String logEntry)
                     throws javax.xml.stream.XMLStreamException,
                            java.io.IOException
* Logs the specified string to the TraceListener if tracing is enabled.

Parameters:
traceType - Kind of trace entry.
logEntry - The entry to log.
Throws:
javax.xml.stream.XMLStreamException - the xML stream exception
java.io.IOException - Signals that an I/O exception has occurred.

traceXml

protected void traceXml(TraceFlags traceType,
                        java.io.ByteArrayOutputStream stream)
Logs the specified XML to the TraceListener if tracing is enabled.

Parameters:
traceType - Kind of trace entry.
stream - The stream containing XML.

traceHttpRequestHeaders

protected void traceHttpRequestHeaders(TraceFlags traceType,
                                       microsoft.exchange.webservices.data.HttpWebRequest request)
                                throws java.net.URISyntaxException,
                                       EWSHttpException,
                                       javax.xml.stream.XMLStreamException,
                                       java.io.IOException
Traces the HTTP request headers.

Parameters:
traceType - Kind of trace entry.
request - The request
Throws:
EWSHttpException
java.net.URISyntaxException
java.io.IOException
javax.xml.stream.XMLStreamException

convertUniversalDateTimeStringToDate

protected java.util.Date convertUniversalDateTimeStringToDate(java.lang.String dateString)
Converts the universal date time string to local date time.

Parameters:
dateString - The value.
Returns:
DateTime Returned date is always in UTC date.

convertStartDateToUnspecifiedDateTime

protected java.util.Date convertStartDateToUnspecifiedDateTime(java.lang.String value)
                                                        throws java.text.ParseException
Converts xs:dateTime string with either "Z", "-00:00" bias, or "" suffixes to unspecified StartDate value ignoring the suffix.Needs to fix E14:232996.

Parameters:
value - The string value to parse.
Returns:
The parsed DateTime value.
Throws:
java.text.ParseException

convertDateTimeToUniversalDateTimeString

protected java.lang.String convertDateTimeToUniversalDateTimeString(java.util.Date dt)
Converts the date time to universal date time string.

Parameters:
dt - the date
Returns:
String representation of DateTime in yyyy-MM-ddTHH:mm:ssZ format.

setCustomUserAgent

protected void setCustomUserAgent(java.lang.String userAgent)
Sets the user agent to a custom value

Parameters:
userAgent - User agent string to set on the service

validate

protected void validate()
                 throws ServiceLocalException
* Validates this instance.

Throws:
ServiceLocalException - the service local exception

setCookie

public void setCookie(java.net.URL url,
                      java.lang.String value)
               throws java.io.IOException,
                      java.net.URISyntaxException
Gets the cookie container. The cookie container.

Parameters:
url - the url
value - the value
Throws:
java.io.IOException - , URISyntaxException
java.net.URISyntaxException - the uRI syntax exception

getCookie

public java.lang.String getCookie(java.net.URL url)
                           throws java.io.IOException,
                                  java.net.URISyntaxException
Gets the cookie.

Parameters:
url - the url
Returns:
the cookie
Throws:
java.io.IOException - Signals that an I/O exception has occurred.
java.net.URISyntaxException - the uRI syntax exception

isTraceEnabled

public boolean isTraceEnabled()
Gets a value indicating whether tracing is enabled.

Returns:
True is tracing is enabled

setTraceEnabled

public void setTraceEnabled(boolean traceEnabled)
Sets a value indicating whether tracing is enabled.

Parameters:
traceEnabled - true to enable tracing

getTraceFlags

public java.util.EnumSet<TraceFlags> getTraceFlags()
Gets the trace flags.

Returns:
Set of trace flags.

setTraceFlags

public void setTraceFlags(java.util.EnumSet<TraceFlags> traceFlags)
Sets the trace flags.

Parameters:
traceFlags - A set of trace flags

getTraceListener

public ITraceListener getTraceListener()
Gets the trace listener.

Returns:
The trace listener.

setTraceListener

public void setTraceListener(ITraceListener traceListener)
Sets the trace listener.

Parameters:
traceListener - the trace listener.

getCredentials

public ExchangeCredentials getCredentials()
Gets the credentials used to authenticate with the Exchange Web Services.

Returns:
credentials

setCredentials

public void setCredentials(ExchangeCredentials credentials)
Sets the credentials used to authenticate with the Exchange Web Services. Setting the Credentials property automatically sets the UseDefaultCredentials to false.

Parameters:
credentials - Exchange credentials.

getUseDefaultCredentials

public boolean getUseDefaultCredentials()
Gets a value indicating whether the credentials of the user currently logged into Windows should be used to authenticate with the Exchange Web Services.

Returns:
true if credentials of the user currently logged in are used

setUseDefaultCredentials

public void setUseDefaultCredentials(boolean value)
* Sets a value indicating whether the credentials of the user currently logged into Windows should be used to authenticate with the Exchange Web Services. Setting UseDefaultCredentials to true automatically sets the Credentials property to null.

Parameters:
value - the new use default credentials

getTimeout

public int getTimeout()
Gets the timeout used when sending HTTP requests and when receiving HTTP responses, in milliseconds.

Returns:
timeout in milliseconds

setTimeout

public void setTimeout(int timeout)
Sets the timeout used when sending HTTP requests and when receiving HTTP respones, in milliseconds. Defaults to 100000.

Parameters:
timeout - timeout in milliseconds

isPreAuthenticate

public boolean isPreAuthenticate()
Gets a value that indicates whether HTTP pre-authentication should be performed.

Returns:
true indicates pre-authentication is set

setPreAuthenticate

public void setPreAuthenticate(boolean preAuthenticate)
Sets a value that indicates whether HTTP pre-authentication should be performed.

Parameters:
preAuthenticate - true to enable pre-authentication

getAcceptGzipEncoding

public boolean getAcceptGzipEncoding()
Gets a value indicating whether GZip compression encoding should be accepted. This value will tell the server that the client is able to handle GZip compression encoding. The server will only send Gzip compressed content if it has been configured to do so.

Returns:
true if compression is used

setAcceptGzipEncoding

public void setAcceptGzipEncoding(boolean acceptGzipEncoding)
Gets a value indicating whether GZip compression encoding should be accepted. This value will tell the server that the client is able to handle GZip compression encoding. The server will only send Gzip compressed content if it has been configured to do so.

Parameters:
acceptGzipEncoding - true to enable compression

getRequestedServerVersion

public ExchangeVersion getRequestedServerVersion()
Gets the requested server version.

Returns:
The requested server version.

getUserAgent

public java.lang.String getUserAgent()
Gets the user agent.

Returns:
The user agent.

setUserAgent

public void setUserAgent(java.lang.String userAgent)
Sets the user agent.

Parameters:
userAgent - The user agent

getServerInfo

public ExchangeServerInfo getServerInfo()
* Gets information associated with the server that processed the last request. Will be null if no requests have been processed.

Returns:
the server info

getWebProxy

public WebProxy getWebProxy()
Gets the web proxy that should be used when sending requests to EWS.

Returns:
Proxy the Proxy Information

setWebProxy

public void setWebProxy(WebProxy value)
Sets the web proxy that should be used when sending requests to EWS. Set this property to null to use the default web proxy.

Parameters:
value - the Proxy Information

getHttpHeaders

public java.util.Map<java.lang.String,java.lang.String> getHttpHeaders()
Gets a collection of HTTP headers that will be sent with each request to EWS.

Returns:
httpHeaders

getOnSerializeCustomSoapHeaders

public java.util.List<microsoft.exchange.webservices.data.ICustomXmlSerialization> getOnSerializeCustomSoapHeaders()
Gets the on serialize custom soap headers.

Returns:
the on serialize custom soap headers

setOnSerializeCustomSoapHeaders

public void setOnSerializeCustomSoapHeaders(java.util.List<microsoft.exchange.webservices.data.ICustomXmlSerialization> onSerializeCustomSoapHeaders)
Sets the on serialize custom soap headers.

Parameters:
onSerializeCustomSoapHeaders - the new on serialize custom soap headers

processHttpResponseHeaders

protected void processHttpResponseHeaders(TraceFlags traceType,
                                          microsoft.exchange.webservices.data.HttpWebRequest request)
                                   throws javax.xml.stream.XMLStreamException,
                                          java.io.IOException,
                                          EWSHttpException
Traces the HTTP response headers.

Parameters:
tracetype - kind of trace entry
response - The response
Throws:
EWSHttpException
java.io.IOException
javax.xml.stream.XMLStreamException

getHttpResponseHeaders

public java.util.Map<java.lang.String,java.lang.String> getHttpResponseHeaders()
Gets a collection of HTTP headers from the last response.


getSessionKey

protected static byte[] getSessionKey()
Gets the session key.