I am trying to consume DFS with JAX-WS consumer. I am using registered service context. While trying to execute a simple query. The result set is always zero. I am not getting any error logged on either in application server or in method server. I am using the DFS which is running on the Jboss method server and trying to access it remotely.
Given below is the code.
import com.emc.documentum.fs.datamodel.core.CacheStrategyType;import com.emc.documentum.fs.datamodel.core.DataObj
import com.emc.documentum.fs.datamodel.core.DataPackage;
import com.emc.documentum.fs.datamodel.core.context.RepositoryIdentity;
import com.emc.documentum.fs.datamodel.core.context.ServiceContext;
import com.emc.documentum.fs.datamodel.core.query.PassthroughQuery;
import com.emc.documentum.fs.datamodel.core.query.QueryExecution;
import com.emc.documentum.fs.datamodel.core.query.QueryResult;
import com.emc.documentum.fs.datamodel.core.query.QueryStatus;
import com.emc.documentum.fs.datamodel.core.query.RepositoryStatusInfo;
import com.emc.documentum.fs.datamodel.core.query.Status;
import com.emc.documentum.fs.rt.services.ContextRegistryService;
import com.emc.documentum.fs.rt.services.ContextRegistryServicePort;
import com.emc.documentum.fs.services.search.SearchService;
import com.emc.documentum.fs.services.search.SearchServicePort;
import com.sun.xml.ws.api.message.Header;
import com.sun.xml.ws.api.message.Headers;
import com.sun.xml.ws.developer.WSBindingProvider;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.ws.WebServiceRef;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
public class JaxWsDfsSearch {
@WebServiceRef(wsdlLocation = "http://**.**.**.**:9080/services/core/SearchService?wsdl")
private SearchService searchService;
@WebServiceRef(wsdlLocation = "http:// **.**.**.**:9080/services/core/runtime/ContextRegistryService?wsdl")
private ContextRegistryService registryService;
private static final String WSSE_NAMESPACE = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";
private static final String WSU_NAMESPACE = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
private static final String EMC_RAD = "http://schemas.emc.com/documentum#ResourceAccessToken";
Element header;
ServiceContext serviceContext;
private String contextRegistryURL, searchServiceURL;
public JaxWsDfsSearch() {
}
public JaxWsDfsSearch(String user, String password, String repository,
String contextRegistryURL, String searchServiceURL)
{
RepositoryIdentity identity = new RepositoryIdentity();
identity.setUserName(user);
identity.setPassword(password);
identity.setRepositoryName(repository);
this.contextRegistryURL = contextRegistryURL;
this.searchServiceURL = searchServiceURL;
serviceContext = new ServiceContext();
serviceContext.getIdentities().add(identity);
}
public String registerContext(ServiceContext s)
{
String token = null;
try
{
registryService = new ContextRegistryService(
new URL(contextRegistryURL),
new QName("http://services.rt.fs.documentum.emc.com/", "ContextRegistryService"));
ContextRegistryServicePort port = registryService.getContextRegistryServicePort();
//second argument in register method is of form "http://host:port/services/core"
token = port.register(s, contextRegistryURL.substring(0, contextRegistryURL.length()-31));
}
catch (Exception e)
{
e.printStackTrace();
}
System.out.println("Registered the service context with token: " + token);
return token;
}
public Element addTokenToHeader(String token)
{
Element wsseSecurity = null;
Element wsseToken;
try
{
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
wsseSecurity = document.createElementNS(
WSSE_NAMESPACE, "wsse:Security"
);
wsseToken = (Element) wsseSecurity.appendChild(document.createElementNS(
WSSE_NAMESPACE, "wsse:BinarySecurityToken"
));
wsseToken.setAttribute("QualificationValueType", EMC_RAD);
wsseToken.setAttributeNS(WSU_NAMESPACE, "wsu:Id", "RAD");
wsseToken.setTextContent(token);
}
catch (ParserConfigurationException e)
{
e.printStackTrace();
}
return wsseSecurity;
}
public void callSearchService()
{
try
{
searchService = new SearchService(
new URL(searchServiceURL),
new QName("http://search.services.fs.documentum.emc.com/","SearchService"));
System.out.println("Retrieving the port from the Search Service");
SearchServicePort port = searchService.getSearchServicePort();
System.out.println("Invoking the getRepositoryInfo operation on the port.");
//Set the security header on the port so the security token is placed in the SOAP request
WSBindingProvider wsbp = ((WSBindingProvider) port);
System.out.println("in security header setting");
Header h = Headers.create(header);
System.out.println("header created");
wsbp.setOutboundHeaders(h);
System.out.println("header added");
//Call the service
QueryResult queryResult;
try
{
String queryString = "select r_object_id from dm_document ";
System.out.println(queryString);
int startingIndex = 0;
int maxResults = 60;
int maxResultsPerSource = 20;
PassthroughQuery q = new PassthroughQuery();
q.setQueryString(queryString);
System.out.println("query set");
QueryExecution queryExec = new QueryExecution();
queryExec.setStartingIndex(startingIndex);
queryExec.setMaxResultCount(maxResults);
queryExec.setMaxResultPerSource(maxResultsPerSource);
queryExec.setCacheStrategyType(CacheStrategyType.NO_CACHE_STRATEGY);
System.out.println("parameter set");
queryResult = port.execute(q, queryExec, null);
System.out.println("Query returned result successfully.");
DataPackage dp = queryResult.getDataPackage();
System.out.println(queryResult.getDataPackage().getDataObjects());
System.out.println("DataPackage contains " + dp.getDataObjects().size() + " objects.");
for (DataObject dataObject : dp.getDataObjects())
{
System.out.println(dataObject.getIdentity());
}
}
catch (Exception e)
{
e.printStackTrace();
throw new RuntimeException(e);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
public void searchDctm() {
}
public void setHeader(Element header)
{
this.header = header;
}
public Element getHeader()
{
return header;
}
public ServiceContext getServiceContext()
{
return serviceContext;
}
public void setServiceContext(ServiceContext serviceContext)
{
this.serviceContext = serviceContext;
}
public static void main(String[] args)
{
try
{
String user = "dmadmin";
String password = "*******";
String repository = "rnd";
String searchServiceURL = "http:// **.**.**.**:9080/services/core/SearchService?wsdl";
String contextRegistryURL = "http:// **.**.**.**.12:9080/services/core/runtime/ContextRegistryService?wsdl";
JaxWsDfsSearch client = new JaxWsDfsSearch(user, password, repository,
contextRegistryURL, searchServiceURL);
String token = client.registerContext(client.getServiceContext());
Element header = client.addTokenToHeader(token);
client.setHeader(header);
client.callSearchService();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
Following is the output:
Registered the service context with token: jaguar/**.**.**.**-1254201994198-6040630915929387660-20
Retrieving the port from the Search Service
Invoking the getRepositoryInfo operation on the port.
in security header setting
header created
header added
select r_object_id from dm_document
query set
parameter set
Query returned result successfully.
[]
DataPackage contains 0 objects.
Do let me know, whether I am missing out anything here.