// Executing the request
Document xmlRequest = DocumentHelper.createDocument();
Element rootElement = xmlRequest.addElement( "batchRequest" );
SearchRequestDsml searchRequestDsml = new SearchRequestDsml( searchRequest );
searchRequestDsml.toDsml( rootElement );
Dsmlv2Engine engine = new Dsmlv2Engine( connection.getHost(), connection.getPort(), connection
.getBindPrincipal(), connection.getBindPassword() );
String response = engine.processDSML( xmlRequest.asXML() );
// Saving the response
FileOutputStream fout = new FileOutputStream( exportDsmlFilename );
new PrintStream( fout ).println( response );
fout.close();