Changeset 11022 for trunk/gsdl3


Ignore:
Timestamp:
2005-12-22T13:19:04+13:00 (18 years ago)
Author:
kjdon
Message:

cleaned out the commented out stuff

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/comms/SOAPCommunicator.java

    r10290 r11022  
    2626import java.net.MalformedURLException;
    2727import 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;
    3428import org.apache.axis.client.Call;
    3529import org.apache.axis.client.Service;
     
    6155    public SOAPCommunicator() {
    6256   
    63 
    64     // Set Encoding Style to standard SOAP encoding
    65     //call_.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
    66     // set Encoding Style to use literal XML
    67     //call_.setEncodingStyleURI(Constants.NS_URI_LITERAL_XML);
    6857    }
    6958       
    7059    public boolean configure(Element site_elem) {
    71 
    7260   
    7361    String type = site_elem.getAttribute(GSXML.TYPE_ATT);
     
    9482        Service service = new Service();
    9583        call_ = (Call) service.createCall();
    96        
    97         //call_.setTargetObjectURI(remote_site_name_);
    98         //call_.setMethodName("process");
    9984        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"));
    10385    } catch (Exception e) {
    10486        System.err.println("SOAPCommunicator.configure() Error: Exception occurred "+e);
     
    173155    comm.configure(site_elem);
    174156    message = "<message><request type=\"describe\" to=\"\" lang=\"en\"/></message>";
    175     //message = "<message><request type=\"describe\" to=\"\" lang=\"en\"/></message>";
    176157    Element request_elem = converter.getDOM(message).getDocumentElement();
    177158    Element response = comm.process(request_elem);
     
    179160    System.err.println("response was "+converter.getPrettyString(response));
    180161    }
    181     /*
    182     public Element process(Element message) {
    183 
    184     NodeList requests = message.getElementsByTagName(GSXML.REQUEST_ELEM);
    185     if (requests.getLength()==0) {
    186         // no requests
    187         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 is
    191     // for now, use local_site_name_ as the flag.
    192     if (local_site_name_!=null) { // no local site
    193        
    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 present
    198         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 on
    205    
    206     // needs to catch SOAPException, MalformedURLException 
    207     try {
    208 
    209         // Set Method Parameters - use literal xml
    210 //      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 Service
    220 //      URL url = new URL(remote_site_address_);
    221        
    222         // Invoke the Service
    223         Response resp = call_.invoke (url, "");
    224        
    225         // Check for Faults
    226         if (!resp.generatedFault()) { // no error
    227         // Extract Return value
    228         Parameter result = resp.getReturnValue ();
    229         Element result_node = (Element) result.getValue();
    230 
    231         if (local_site_name_ != null) {// have to modify the from field
    232 
    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 is
    241         return result_node;
    242         }
    243         else { // error
    244         //  Extract Fault Code and String
    245         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     */
    262162}
    263163
Note: See TracChangeset for help on using the changeset viewer.