Index: /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/comms/SOAPCommunicator.java
===================================================================
--- /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/comms/SOAPCommunicator.java	(revision 9504)
+++ /branches/ant-install-branch/gsdl3/src/java/org/greenstone/gsdl3/comms/SOAPCommunicator.java	(revision 9505)
@@ -26,10 +26,14 @@
 import java.net.MalformedURLException;
 import java.util.Vector;
-import org.apache.soap.SOAPException;
-import org.apache.soap.Fault;
-import org.apache.soap.Constants;
-import org.apache.soap.rpc.Call;
-import org.apache.soap.rpc.Parameter;
-import org.apache.soap.rpc.Response;
+// import org.apache.soap.SOAPException;
+// import org.apache.soap.Fault;
+// import org.apache.soap.Constants;
+// import org.apache.soap.rpc.Call;
+// import org.apache.soap.rpc.Parameter;
+// import org.apache.soap.rpc.Response;
+import org.apache.axis.client.Call;
+import org.apache.axis.client.Service;
+import org.apache.axis.message.SOAPBodyElement;
+import javax.xml.namespace.QName;
 
 import org.w3c.dom.Node; 
@@ -57,13 +61,14 @@
     public SOAPCommunicator() {
 	
-	call_ = new Call();
+
 	// Set Encoding Style to standard SOAP encoding
 	//call_.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
 	// set Encoding Style to use literal XML
-	call_.setEncodingStyleURI(Constants.NS_URI_LITERAL_XML);
+	//call_.setEncodingStyleURI(Constants.NS_URI_LITERAL_XML);
     }
         
     public boolean configure(Element site_elem) {
 
+	
 	String type = site_elem.getAttribute(GSXML.TYPE_ATT);
 	if (!type.equals(GSXML.COMM_TYPE_SOAP_JAVA)) {
@@ -81,13 +86,23 @@
 	    return false;
 	}
-	call_.setTargetObjectURI(remote_site_name_);
-	call_.setMethodName("process");
-
+	try {
+	    Service service = new Service();
+	    call_ = (Call) service.createCall();
+	    
+	    //call_.setTargetObjectURI(remote_site_name_);
+	    //call_.setMethodName("process");
+	    call_.setTargetEndpointAddress( new java.net.URL(remote_site_address_) );
+	    //	    call_.setOperationStyle(org.apache.axis.enum.Style.MESSAGE_STR);
+	    //call_.setOperationUse(org.apache.axis.enum.Use.LITERAL_STR); 
+	    //call_.setOperationName(new QName("http://soapinterop.org/", "process"));
+	} catch (Exception e) {
+	    System.err.println("SOAPCommunicator.configure() Error: Exception occurred "+e);
+	    return false;
+	}
 	return true;
     }
 
-
     public Element process(Element message) {
-
+	
 	NodeList requests = message.getElementsByTagName(GSXML.REQUEST_ELEM);
 	if (requests.getLength()==0) {
@@ -95,5 +110,5 @@
 	    return null;
 	}
-	
+
 	// if the communicator is part of a site, it needs to edit the to and from fields, otherwise it just passes the message on, as is
 	// for now, use local_site_name_ as the flag.
@@ -110,4 +125,76 @@
 	    }
 	}
+	// else do nothing to the requests, just pass it on
+
+	// the soap impl needs a namespace for the top level element
+	Element message_to_send = message;
+	if (message.getNamespaceURI() == null) {
+	    message_to_send = GSXML.duplicateWithNewNameNS(message.getOwnerDocument(), message, "gs3:"+message.getTagName(), "urn:foo", true);
+	    //System.err.println("**"+new XMLConverter().getPrettyString(new_message));
+	}
+	
+	// do the soap query
+	Element result = null;
+	try {
+	    SOAPBodyElement[] input = new SOAPBodyElement[1];
+	    input[0] = new SOAPBodyElement(message_to_send);
+	    Vector output = (Vector) call_.invoke( input );
+	    SOAPBodyElement elem = (SOAPBodyElement) output.get(0);
+	    result = elem.getAsDOM();
+	} catch (Exception e) {
+	    e.printStackTrace();
+	    return null;
+	}
+	
+	if (local_site_name_ != null) {// have to modify the from field
+	    
+	    NodeList responses = result.getElementsByTagName(GSXML.RESPONSE_ELEM);
+	    for (int i=0;i<responses.getLength(); i++) {
+		Element e = (Element)responses.item(i);
+		String from = e.getAttribute(GSXML.FROM_ATT);
+		from = GSPath.prependLink(from, remote_site_name_);
+		e.setAttribute(GSXML.FROM_ATT, from);
+	    }
+	} // else return as is
+	
+	return result;
+    }
+
+    public static void main (String [] args) {
+	SOAPCommunicator comm = new SOAPCommunicator();
+	XMLConverter converter = new XMLConverter();
+	String message = "<site name=\"localsite\" address=\"http://kanuka.cs.waikato.ac.nz:7070/axis/services/localsite\" type=\"soap\"/>";
+	Element site_elem = converter.getDOM(message).getDocumentElement();
+	comm.configure(site_elem);
+	message = "<message><request type=\"describe\" to=\"\" lang=\"en\"/></message>";
+	//message = "<message><request type=\"describe\" to=\"\" lang=\"en\"/></message>";
+	Element request_elem = converter.getDOM(message).getDocumentElement();
+	Element response = comm.process(request_elem);
+	
+	System.err.println("response was "+converter.getPrettyString(response));
+    }
+    /*
+    public Element process(Element message) {
+
+	NodeList requests = message.getElementsByTagName(GSXML.REQUEST_ELEM);
+	if (requests.getLength()==0) {
+	    // no requests
+	    return null;
+	}
+	
+	// if the communicator is part of a site, it needs to edit the to and from fields, otherwise it just passes the message on, as is
+	// for now, use local_site_name_ as the flag.
+	if (local_site_name_!=null) { // no local site
+	    
+	    for (int i=0;i<requests.getLength(); i++) {
+		Element e = (Element)requests.item(i);
+		String to = e.getAttribute(GSXML.TO_ATT);
+		to = GSPath.removeFirstLink(to); // remove the server name, should check that it is present
+		e.setAttribute(GSXML.TO_ATT, to);
+		String from = e.getAttribute(GSXML.FROM_ATT);
+		from = GSPath.appendLink(from, local_site_name_);
+		e.setAttribute(GSXML.FROM_ATT, from);
+	    }
+	}
 	// else do nothing to the message, just pass it on
 	
@@ -116,15 +203,15 @@
 
 	    // Set Method Parameters - use literal xml
-	    Parameter param = new Parameter("xml_in", 
-					    org.w3c.dom.Element.class,
-					    message, 
-					    Constants.NS_URI_LITERAL_XML);
+// 	    Parameter param = new Parameter("xml_in", 
+// 					    org.w3c.dom.Element.class,
+// 					    message, 
+// 					    Constants.NS_URI_LITERAL_XML);
 					    
-	    Vector param_list = new Vector ();
-	    param_list.addElement (param);
-	    call_.setParams (param_list);
-	    
-	    //  Set the URL for the Web Service
-	    URL url = new URL(remote_site_address_);
+// 	    Vector param_list = new Vector ();
+// 	    param_list.addElement (param);
+// 	    call_.setParams (param_list);
+	    
+// 	    //  Set the URL for the Web Service
+// 	    URL url = new URL(remote_site_address_);
 	    
 	    // Invoke the Service
@@ -167,5 +254,5 @@
 	}
     }
-    
+    */
 }
 
