📄 queryservicedatabyxpath.java
字号:
package org.osu.ogsa.stream.util;import org.globus.ogsa.utils.AnyHelper;import org.globus.ogsa.utils.GetOpts;import org.globus.ogsa.utils.MessageUtils;import org.globus.ogsa.utils.QueryHelper;import org.gridforum.ogsi.ExtensibilityType;import org.gridforum.ogsi.GridService;import org.gridforum.ogsi.HandleType;import org.gridforum.ogsi.OGSIServiceGridLocator;import org.apache.axis.utils.XMLUtils;import org.w3c.dom.Element;import javax.xml.namespace.QName;import javax.xml.rpc.Stub;public class QueryServiceDataByXPath{ public static Element [] Query( String service_data, String service_handle, String xpath_express) { String service_data_namespace = "http://stdsun.cis.ohio-state.edu/chenlia"; String namespace_mappings = "xmlns:ce=http://glue.base.ogsa.globus.org/ce/1.1"; return Query(service_data_namespace, service_data, service_handle, xpath_express, namespace_mappings); } public static Element [] Query(String service_data_namespace, String service_data, String service_handle, String xpath_express, String namespace_mappings) { if(service_data_namespace == null) service_data_namespace = "http://stdsun.cis.ohio-state.edu/chenlia"; String namespace = service_data_namespace; String name = service_data; String handle = service_handle; String xpath = xpath_express; String namespaceMappings = namespace_mappings; String[] namespaces = QueryHelper.tokenizeNamespaces(namespaceMappings); try { OGSIServiceGridLocator locator = new OGSIServiceGridLocator(); GridService service = locator.getGridServicePort(new HandleType(handle));// opts.setOptions(((Stub)service)); QName qname = new QName(namespace, name); ExtensibilityType queryResult = service.findServiceData(QueryHelper.getXPathQuery(qname,xpath,namespaces)); if (queryResult.get_any() == null) return null; else { //Debug Element result[] = AnyHelper.getAsElement(queryResult);/* System.out.println("the length is " + result.length); for(int i = result.length - 1; i >=0 ; i--) XMLUtils.PrettyElementToStream(result[i], System.out);*/ return result; } }catch (Exception e) { System.err.println(MessageUtils.toString(e)); return null; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -