Magentix2
2.1.1
|
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() |
This class provides tools in order to facilitate the execution of the services.
Definition at line 12 of file ServiceTools.java.
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
serviceName | The name of the service |
inputs | is a HashMap formed by keys and values |
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
serviceWSDLURL | to execute |
xmlInputs | inputs in a XML structure with name of the input and its value ex. <inputs><inputX>valueX</inputX></inputs> |
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
serviceWSDLURL | to execute |
inputs | HashMap with name of the input 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
string | with a XML format, in this XML will be contained the service name and service input or outputs |
inOutputs | is a new HashMap. In this HashMap the service inputs or outputs are added |
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; }
ResponseParser es.upv.dsic.gti_ia.organization.ServiceTools.rp = new ResponseParser() [package] |
Definition at line 26 of file ServiceTools.java.