Changeset 11022
- Timestamp:
- 2005-12-22T13:19:04+13:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/comms/SOAPCommunicator.java
r10290 r11022 26 26 import java.net.MalformedURLException; 27 27 import java.util.Vector; 28 // import org.apache.soap.SOAPException;29 // import org.apache.soap.Fault;30 // import org.apache.soap.Constants;31 // import org.apache.soap.rpc.Call;32 // import org.apache.soap.rpc.Parameter;33 // import org.apache.soap.rpc.Response;34 28 import org.apache.axis.client.Call; 35 29 import org.apache.axis.client.Service; … … 61 55 public SOAPCommunicator() { 62 56 63 64 // Set Encoding Style to standard SOAP encoding65 //call_.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);66 // set Encoding Style to use literal XML67 //call_.setEncodingStyleURI(Constants.NS_URI_LITERAL_XML);68 57 } 69 58 70 59 public boolean configure(Element site_elem) { 71 72 60 73 61 String type = site_elem.getAttribute(GSXML.TYPE_ATT); … … 94 82 Service service = new Service(); 95 83 call_ = (Call) service.createCall(); 96 97 //call_.setTargetObjectURI(remote_site_name_);98 //call_.setMethodName("process");99 84 call_.setTargetEndpointAddress( new java.net.URL(remote_site_address_) ); 100 // call_.setOperationStyle(org.apache.axis.enum.Style.MESSAGE_STR);101 //call_.setOperationUse(org.apache.axis.enum.Use.LITERAL_STR);102 //call_.setOperationName(new QName("http://soapinterop.org/", "process"));103 85 } catch (Exception e) { 104 86 System.err.println("SOAPCommunicator.configure() Error: Exception occurred "+e); … … 173 155 comm.configure(site_elem); 174 156 message = "<message><request type=\"describe\" to=\"\" lang=\"en\"/></message>"; 175 //message = "<message><request type=\"describe\" to=\"\" lang=\"en\"/></message>";176 157 Element request_elem = converter.getDOM(message).getDocumentElement(); 177 158 Element response = comm.process(request_elem); … … 179 160 System.err.println("response was "+converter.getPrettyString(response)); 180 161 } 181 /*182 public Element process(Element message) {183 184 NodeList requests = message.getElementsByTagName(GSXML.REQUEST_ELEM);185 if (requests.getLength()==0) {186 // no requests187 return null;188 }189 190 // 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 is191 // for now, use local_site_name_ as the flag.192 if (local_site_name_!=null) { // no local site193 194 for (int i=0;i<requests.getLength(); i++) {195 Element e = (Element)requests.item(i);196 String to = e.getAttribute(GSXML.TO_ATT);197 to = GSPath.removeFirstLink(to); // remove the server name, should check that it is present198 e.setAttribute(GSXML.TO_ATT, to);199 String from = e.getAttribute(GSXML.FROM_ATT);200 from = GSPath.appendLink(from, local_site_name_);201 e.setAttribute(GSXML.FROM_ATT, from);202 }203 }204 // else do nothing to the message, just pass it on205 206 // needs to catch SOAPException, MalformedURLException207 try {208 209 // Set Method Parameters - use literal xml210 // Parameter param = new Parameter("xml_in",211 // org.w3c.dom.Element.class,212 // message,213 // Constants.NS_URI_LITERAL_XML);214 215 // Vector param_list = new Vector ();216 // param_list.addElement (param);217 // call_.setParams (param_list);218 219 // // Set the URL for the Web Service220 // URL url = new URL(remote_site_address_);221 222 // Invoke the Service223 Response resp = call_.invoke (url, "");224 225 // Check for Faults226 if (!resp.generatedFault()) { // no error227 // Extract Return value228 Parameter result = resp.getReturnValue ();229 Element result_node = (Element) result.getValue();230 231 if (local_site_name_ != null) {// have to modify the from field232 233 NodeList responses = result_node.getElementsByTagName(GSXML.RESPONSE_ELEM);234 for (int i=0;i<responses.getLength(); i++) {235 Element e = (Element)responses.item(i);236 String from = e.getAttribute(GSXML.FROM_ATT);237 from = GSPath.prependLink(from, remote_site_name_);238 e.setAttribute(GSXML.FROM_ATT, from);239 }240 } // else return as is241 return result_node;242 }243 else { // error244 // Extract Fault Code and String245 Fault f = resp.getFault();246 String faultCode = f.getFaultCode();247 String faultString = f.getFaultString();248 System.err.println("Fault Occurred (details follow):");249 System.err.println("Fault Code: "+faultCode);250 System.err.println("Fault String: "+faultString);251 return converter_.getDOM("<"+GSXML.MESSAGE_ELEM+">Fault Occurred. No greeting for you!</"+GSXML.MESSAGE_ELEM+">").getDocumentElement();252 }253 } catch (SOAPException e) {254 System.out.println("SOAP error:"+e.getMessage());255 return null;256 } catch (MalformedURLException e) {257 System.out.println("URL error:"+e.getMessage());258 return null;259 }260 }261 */262 162 } 263 163
Note:
See TracChangeset
for help on using the changeset viewer.