AnsweredAssumed Answered

WSSecurityException when using fetchMore method

Question asked by rubberballman on Dec 9, 2014
Can someone tell me what's wrong with my code here… I'm always getting this exception on the first call to <strong>…)</strong> after the first fetchMore has occurred.

<strong> The security token could not be authenticated or authorized</strong>

// Here we're setting the endpoint address manually, this way we don't need to use
AuthenticationUtils.startSession(wsUsername, wsPassword);

// Set the batch size in the query header
int batchSize = 5000;
QueryConfiguration queryCfg = new QueryConfiguration();
RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();
repositoryService.setHeader(new RepositoryServiceLocator().getServiceName().getNamespaceURI(), "QueryHeader", queryCfg);
ContentServiceSoapBindingStub contentService = WebServiceFactory.getContentService();

String luceneQuery = buildLuceneQuery(categories, properties);

// Call the repository service to do search based on category
Query query = new Query(Constants.QUERY_LANG_LUCENE, luceneQuery);

// Execute the query
QueryResult queryResult = repositoryService.query(STORE, query, true);
String querySession = queryResult.getQuerySession();
while (querySession != null) {           
    ResultSet resultSet = queryResult.getResultSet();
    ResultSetRow[] rows = resultSet.getRows();
    for (ResultSetRow row : rows) {
        // Read the content from the repository
        Content[] readResult = Predicate(new Reference[] { new Reference(STORE, row.getNode().getId(), null) },
            STORE, null), Constants.PROP_CONTENT);
        Content content = readResult[0];
    // Get the next batch of results
    queryResult = repositoryService.fetchMore(querySession);
    // process subsequent query results
    querySession = queryResult.getQuerySession();