|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface ExchangeServiceClient
Represents an HTTP client accessing the Exchange Web Services (EWS). The method sendRequest is used to send a SOAP request over HTTP to the Exchange server and returns the received response.
A custom client can be used by implementing this interface. Usage example:
public class CustomServiceClient implements ExchangeServiceClient
{
public ExchangeResponse sendRequest(ExchangeRequest request) throws ExchangeServiceException
{
try
{
HttpURLConnection connection = (HttpURLConnection) new URL("https://server/ews/Exchange.asmx").openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestMethod("POST");
connection.connect();
request.writeTo(connection.getOutputStream());
return new ExchangeResponse(connection.getResponseCode(), connection.getResponseMessage(), connection.getInputStream());
}
catch(IOException ex)
{
}
return null;
}
}
A proxy client can also be implemented. Below is an example code showing how to print to the console all requests and responses exchanged:
public class ConsoleProxyClient implements ExchangeServiceClient
{
private ExchangeServiceClient client;
public ConsoleProxyClient(ExchangeServiceClient client) { this.client = client; }
public ExchangeResponse sendRequest(ExchangeRequest request) throws ExchangeServiceException
{
System.out.println("Request: " + request.toString());
ExchangeResponse response = client.sendRequest(request);
System.out.print("Response: " + response.toString());
return response;
}
}
Exchange exchange = ...;
exchange.setClient(new ConsoleProxyClient(exchange.getClient()));
Nested Class Summary | |
---|---|
static class |
ExchangeServiceClient.ExchangeRequest
|
static class |
ExchangeServiceClient.ExchangeResponse
|
Method Summary | |
---|---|
ExchangeServiceClient.ExchangeResponse |
sendRequest(ExchangeServiceClient.ExchangeRequest request)
|
Method Detail |
---|
ExchangeServiceClient.ExchangeResponse sendRequest(ExchangeServiceClient.ExchangeRequest request) throws ExchangeServiceException
ExchangeServiceException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |