HI,
I am getting an issue when trying to get service provider for a project in one particular server whereas it works fine for another server.
Is there a difference for XPathConstants.NODE between
Node
and
{http://www.w3.org/1999/XSL/Transform}NODE
private static String getServiceProvider(String catalogURI, String paName,String server,String login,String password,HttpClient httpclient) throws InvalidCredentialsException, IOException, XPathExpressionException {
HttpGet query = new HttpGet(catalogURI);
query.addHeader("Accept", "application/xml");
query.addHeader("OSLC-Core-Version", "2.0");
System.out.println("paName 111111111111 "+paName);
// Access to the Service Providers catalog
HttpResponse response = HttpUtil.sendGetForSecureDocument(
server, query, login, password, httpclient);
if (response.getStatusLine().getStatusCode() != 200) {
response.getEntity().consumeContent();
throw new HttpResponseException(response.getStatusLine().getStatusCode(), response.getStatusLine().getReasonPhrase());
}
// Define the XPath evaluation environment
XPathFactory factory = XPathFactory.newInstance();
XPath xpath = factory.newXPath();
String serviceProviderXPath = "//oslc:ServiceProvider[dcterms:title=\""+paName+"\"]/@rdf:about";
xpath.setNamespaceContext(
new NamespaceContextMap(new String[]
{"oslc", "http://open-services.net/ns/core#",
"rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"dcterms", "http://purl.org/dc/terms/"}));
// Retrieve the designated Service Provider
InputSource source = new InputSource(response.getEntity().getContent());
Node paNode = (Node)(xpath.evaluate(serviceProviderXPath, source, XPathConstants.NODE));
if (paNode == null) {
response.getEntity().consumeContent();
throw new RuntimeException("Unknown Project Area: "+paName);
}
return paNode.getTextContent();
}