// 4) Creates a proxy handler for service invocation.
ProxyHandler metadataProxyHandler = createProxyHandler();
// 5) ..and invokes the GetMetadata on the first member.
WsResourceClient wsResourceClient = resources[0];
wsResourceClient.setTrace(true);
// Dialect is RDM for this example
String dialect = "http://docs.oasis-open.org/wsrf/rmd-1";
Object [] inputParameters = {dialect};
// RDM is the first element of the returned array.
// The first element is a wsx:Metadata containing all resource properties.
Element [] metadata = (Element[]) wsResourceClient.invoke(metadataProxyHandler, inputParameters);
Element resourceMetadataDescriptor = metadata[0];
// 6) using XPath navigates xml in order to get the list of all properties.
Element [] properties = XmlUtils.findInSubTree(
resourceMetadataDescriptor,
new QName("http://docs.oasis-open.org/wsrf/rmd-1","Property","wsrmd"));
List<QName> names = new ArrayList<QName>();
for (Element property : properties)
{
String attributeName = property.getAttribute("name"); // = qman:<Attribute Name>
// For this example we are only interested on qman namespace related properties...
if (attributeName.startsWith("qman"))
{
String attributeNameWithoutPrefix = attributeName.replaceFirst("qman:", ""); // = <Attribute Name>
names.add(new QName(
"http://amqp.apache.org/qpid/management/qman",
attributeNameWithoutPrefix,
"qman"));
}
}
QName [] qnames = names.toArray(new QName[names.size()]);
// 7) Send a GetMultipleResourcePropertiesRequest.
// We do nothing with the returned value(s) because it / they
// has / have already printed out (wsResourceClient.setTrace(true))
@SuppressWarnings("unused")
Element [] values = wsResourceClient.getMultipleResourceProperties(qnames);
}