Moyosoft Products | Services | Download | Contact us    
Java Bridge to Exchange
Products  >  Java Bridge to Exchange  >  API Reference    
API Reference
Overview  |  
Classic JavaDoc

Interface ExchangeServiceClient

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
      HttpURLConnection connection = (HttpURLConnection) new URL("https://server/ews/Exchange.asmx").openConnection();


      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()));


Community comments

Powered by JavaDocPlus