Index: /trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/notifier/NotifierManager.java
===================================================================
--- /trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/notifier/NotifierManager.java	(revision 8644)
+++ /trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/notifier/NotifierManager.java	(revision 8645)
@@ -6,9 +6,14 @@
 import java.net.*;
 import java.sql.*;
-import java.util.Calendar;
+import java.text.SimpleDateFormat;
+import java.util.*;
 import java.util.Date;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
+import java.util.TreeMap;
 
+import org.apache.soap.Constants;
+import org.apache.soap.SOAPException;
+import org.apache.soap.rpc.*;
+import org.apache.soap.rpc.Call;
+import org.apache.soap.rpc.Parameter;
 import org.greenstone.gsdl3.gs3build.CollectionManager;
 import org.greenstone.gsdl3.gs3build.util.GS3SQLConnection;
@@ -30,5 +35,5 @@
             // AccessionDate >= CollectionLastRebuiltDate
         	ResultSet results = statement.executeQuery("SELECT DocID FROM document WHERE DocType != 'GSMETADATA' AND AccessionDate >= " + lastBuild);
-        	notify(collectionName, host, results, collManager.getDatabase());
+        	notify(collectionName, host, results, collManager.getDatabase(), "new_document");
         	
         	// detect modified documents. A document is modified if and only if
@@ -36,5 +41,5 @@
         	// ModifiedDate >= IndexedDate
         	results = statement.executeQuery("SELECT DocID FROM document WHERE DocType != 'GSMETADATA' AND AccessionDate < " + lastBuild + " AND ModifiedDate >= IndexedDate");
-        	notify(collectionName, host, results, collManager.getDatabase());
+        	notify(collectionName, host, results, collManager.getDatabase(), "document_modified");
         } catch (SQLException e) {
         	// TODO Auto-generated catch block
@@ -47,4 +52,5 @@
      * @param hostURL
      * @param results
+     * @param eventType TODO
      * @throws MalformedURLException
      * @throws IOException
@@ -52,39 +58,40 @@
      * @throws SQLException
      */
-	private void notify(String collName, String hostURL, ResultSet results, GS3SQLConnection database) {
+	private void notify(String collName, String hostURL, ResultSet results, GS3SQLConnection database, String eventType) {
 	    try {
-	        URL url = new URL("http://localhost:8080/alerting/service?receive");
-	        System.out.println("trying to POST to " + url);
-	        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
-	        conn.setDoOutput(true);
-	        conn.setRequestMethod("POST");
-	        conn.setUseCaches(false);
+	        URL url = new URL(hostURL);
+	        System.out.println("trying to send (via SOAP) to " + url);
+	        
 	        while(results.next()) {
 	            System.out.println("new document: " + results.getString("DocID"));
+	            Map event = new TreeMap();
+	            
+                String documentID = results.getString("DocID");
+                
+                event.put("documentID", documentID);
+                event.put("type", eventType);
+	            event.put("collectionID", collName);
+	            event.put("host_url", hostURL);
+	            event.put("document_title", getDocumentTitle(documentID, database));
+	            
+	            Call call = new Call();
+	            call.setTargetObjectURI("alerting");
+	            call.setMethodName("receiveEvent");
+	            call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
+	            Vector params = new Vector();
+	            params.addElement(new Parameter("event", Map.class, event, null));
+	            call.setParams(params);
 	            try {
-	                conn.connect();
-	                OutputStream toReceiver = conn.getOutputStream();
-	                OutputStreamWriter writeToReceiver = new OutputStreamWriter(toReceiver);
-	                
-	                // TODO HTTP Post -> SOAP
-	                String documentID = results.getString("DocID");
-	                
-	                writeToReceiver.write("type=new_document&");
-	                writeToReceiver.write("collectionID=" + collName + "&");
-	                writeToReceiver.write("host_url=" + hostURL + "&");
-	                writeToReceiver.write("document_title=" + getDocumentTitle(documentID, database) + "&");
-	                writeToReceiver.write("documentID=" + documentID + "\n");
-	                writeToReceiver.close();
-	                
-	                System.out.println(conn.getResponseCode());
-	                InputStream fromReceiver = conn.getInputStream();
-	                int i;
-	                while ((i = fromReceiver.read()) != -1) System.out.write(i);
-	                conn.disconnect();
-	            } catch (IOException e1) {
-	                // TODO Auto-generated catch block
-	                System.out.println("Error talking to server.");
-	                e1.printStackTrace();
-	            }
+                    Response resp = call.invoke(url, "");
+                    if (!resp.generatedFault()) {
+                        System.out.println("successfully posted event");
+                        return;
+                    }
+                    System.err.println("Posting event was unsuccessful:");
+                    System.err.println(resp.getFault().getFaultString());
+                } catch (SOAPException e1) {
+                    System.err.println("Exception while posting event: ");
+                    e1.printStackTrace();
+                }
 	        }
 	    } catch (IOException e) {
