| Classic JavaDoc |
Interface ExchangeServiceClient
com.moyosoft.exchange.util.ExchangeServiceClient
public interface ExchangeServiceClient
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()));
Methods
Community comments
Powered by JavaDocPlus