Forum Discussion

Denni's avatar
Denni
Occasional Contributor
16 years ago

Webservice search problem

hey...
I got my webservice works so far and now i want to test it with
SoapUI. The problem is I don't know what I have to do now to test it
and to complete my java codes. I hope you can help me.

My Webservice


package web.service;

/**
* WebServiceSearch
*
* @author Denni Nußbaum
*/


import javax.ejb.EJB;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.naming.InitialContext;

import ejb.search.*;


@WebService(name = "SearchService", serviceName = "SearchService", targetNamespace = "http://www.test.de")
public class WebServiceSearch {

@EJB
SearchLocal searchBean;

SearchLocal getSearchBean() {

if (searchBean == null) {

try {
searchBean = (SearchLocal) new InitialContext()
.lookup("java:comp/env/ejb/SearchEJB");
} catch (Exception a) {
throw new RuntimeException(a);
}
}
return searchBean;
}


//@WebMethod
//public java.util.ArrayList<String> getItems(java.lang.String searchTerm) {
  // new java.util.ArrayList<String>();


@WebMethod
public void searchInDocumentFieldsForSimpleSearch(final String and_search, final Long userId)
{
return;
}




This is the search method "searchInDocumentFieldsForSimpleSearch"


@SuppressWarnings("unchecked")
public List<Document> searchInDocumentFieldsForSimpleSearch(
final String and_search, final Long userId) {

final List<Long> documentIds = new ArrayList<Long>(0);
final List<Long> visibledocumentsForUser_ids = new ArrayList<Long>(0);
final List<Document> documents = new ArrayList<Document>(0);

final Session session = sf.openSession();
final FullTextSession fullTextSession = Search
.createFullTextSession(session);

// determine visible documents by user
visibledocumentsForUser_ids.addAll(dfl
.getVisibleDocumentsByUser(userId));

final String newSearch = and_search.trim();
final Query luceneQuery = createInputFieldQuery(newSearch,
BooleanClause.Occur.MUST, false);

final org.hibernate.Query fullTextQuery = fullTextSession
.createFullTextQuery(luceneQuery, Document.class);
final Iterator it = fullTextQuery.iterate();

// while (it.hasNext()) {
// final DocumentField df = (DocumentField) it.next();
// if (df != null) {
// if (!documentIds.contains(df.getDocumentId())
// && (visibledocumentsForUser_ids
// .contains(df.getDocumentId()))) {
// final Document dd = df.getDocument();
// if(dd!=null){
// if(Hibernate.isInitialized(dd)==false){
// Hibernate.initialize(dd);
// }
// documentIds.add(dd.getId());
// documents.add(dd);
// }
// }
// }
// }

while (it.hasNext()) {
final Document d = (Document) it.next();
if (d != null) {
if (!documentIds.contains(d.getId())
&& (visibledocumentsForUser_ids.contains(d.getId()))) {
documentIds.add(d.getId());
documents.add(d);
}
}
}

/*
* visibledocumentsForUser_ids.addAll(dfl
* .getVisibleDocumentsByUser(userId));
*
* Iterator is = documentFields.iterator(); while (is.hasNext()) {
* DocumentField df = (DocumentField) is.next(); if(df!=null){ Document
* dd = df.getDocument(); dd.getAuthors(); if
* (!documentIds.contains(dd.getId()) &&
* (visibledocumentsForUser_ids.contains(dd.getId()))) {
*
* documentIds.add(dd.getId()); documents.add(dd); // System.out //
* .println("###### Document " + dd.getName() + " " // +
* dd.getCreationDate() + " " // + dd.getModificationDate()); // hier
* implemantation für die categorien anzeige ?? } } }
*/
return documents;

}

/*
* (non-Javadoc)
*
* @seede.ejb.search.SearchLocal#
* getAllDocumentsByUserCommunitiesAndByReleaseStatus(java.lang.Long)
*/


now i compile it and open the wsdl with SoapUI.
Than I want to test the search function, but i don't know how and
what do I have to put in my code to make it works.
I hope you can help me so far.
thank