Magentix2  2.1.1
es.upv.dsic.gti_ia.organization.ServiceTools Class Reference
Collaboration diagram for es.upv.dsic.gti_ia.organization.ServiceTools:

List of all members.

Classes

class  OntologicalTypesConstants

Public Member Functions

String buildServiceContent (String serviceName, HashMap< String, String > inputs)
String extractServiceContent (String xml, HashMap< String, String > inOutputs)
HashMap< String, Object > executeWebService (String serviceWSDLURL, String xmlInputs)
HashMap< String, Object > executeWebService (String serviceWSDLURL, HashMap< String, String > inputs)

Package Attributes

ResponseParser rp = new ResponseParser()

Detailed Description

This class provides tools in order to facilitate the execution of the services.

Definition at line 12 of file ServiceTools.java.


Member Function Documentation

String es.upv.dsic.gti_ia.organization.ServiceTools.buildServiceContent ( String  serviceName,
HashMap< String, String >  inputs 
)

Builds a new string with a XML format. This XML is formed by service name and list of the inputs

Parameters:
serviceNameThe name of the service
inputsis a HashMap formed by keys and values
Returns:
string with a XML format.

Definition at line 38 of file ServiceTools.java.

                                                                                              {
                String resultXML = "";

                resultXML += "<serviceInput>\n";
                resultXML += "<serviceName>" + serviceName + "</serviceName>\n";
                resultXML += "<inputs>\n";
                for (Entry<String, String> e : inputs.entrySet()) {
                        resultXML += "<" + e.getKey() + ">" + e.getValue() + "</" + e.getKey() + ">\n";
                }
                resultXML += "</inputs>\n";
                resultXML += "</serviceInput>\n";
                return resultXML;

        }
HashMap<String, Object> es.upv.dsic.gti_ia.organization.ServiceTools.executeWebService ( String  serviceWSDLURL,
String  xmlInputs 
)

Executes the Web Service of the given WSDL URL with the provided inputs. Returns the results of the service execution

Parameters:
serviceWSDLURLto execute
xmlInputsinputs in a XML structure with name of the input and its value ex. <inputs><inputX>valueX</inputX></inputs>
Returns:
HashMap with the output results with name of the output and its value

Definition at line 93 of file ServiceTools.java.

                                                                                                  {
                HashMap<String, String> inputs = new HashMap<String, String>();
                this.extractServiceContent(xmlInputs, inputs);
                return this.executeWebService(serviceWSDLURL, inputs);
        }
HashMap<String, Object> es.upv.dsic.gti_ia.organization.ServiceTools.executeWebService ( String  serviceWSDLURL,
HashMap< String, String >  inputs 
)

Executes the Web Service of the given WSDL URL with the provided inputs. Returns the results of the service execution

Parameters:
serviceWSDLURLto execute
inputsHashMap with name of the input and its value
Returns:
HashMap with the output results with name of the output and its value

Definition at line 110 of file ServiceTools.java.

                                                                                                                {

                Oracle oracle = new Oracle();
                oracle.parseWSDL(serviceWSDLURL);

                ArrayList<String> processInputs = oracle.getWSDLInputs();

                HashMap<String, String> paramsComplete = new HashMap<String, String>();
                Iterator<String> iterProcessInputs = processInputs.iterator();
                while (iterProcessInputs.hasNext()) {
                        String in = iterProcessInputs.next();
                        // initialize the inputs
                        paramsComplete.put(in, "");
                }

                for (Entry<String, String> e : inputs.entrySet()) {

                        if (paramsComplete.get(e.getKey()) != null) {
                                paramsComplete.put(e.getKey(), e.getValue());
                        }
                }

                // construct parameters list with the value of the parameters ordered
                ArrayList<String> params = new ArrayList<String>();
                Iterator<String> iterInputs = processInputs.iterator();
                while (iterInputs.hasNext()) {
                        String input = iterInputs.next();
                        params.add(paramsComplete.get(input));
                }

                ServiceClient serviceClient = new ServiceClient();
                HashMap<String, Object> results = serviceClient.invoke(serviceWSDLURL, params);

                return results;
        }
String es.upv.dsic.gti_ia.organization.ServiceTools.extractServiceContent ( String  xml,
HashMap< String, String >  inOutputs 
)

Parses a XML in order to extract the service name and fill the HashMap with the service inputs or outputs

Parameters:
stringwith a XML format, in this XML will be contained the service name and service input or outputs
inOutputsis a new HashMap. In this HashMap the service inputs or outputs are added
Returns:
service name

Definition at line 65 of file ServiceTools.java.

                                                                                           {

                rp.parseResponse(xml);

                String serviceName = rp.getServiceName();

                HashMap<String, String> outputAux = rp.getKeyAndValueList();

                for (Entry<String, String> e : outputAux.entrySet()) {

                        inOutputs.put(e.getKey(), e.getValue());
                }

                return serviceName;
        }

Member Data Documentation


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables