SiteCategoriesWebServs; /** * Created: 2013.09.22.5.40.AM * SiteCategoriesWebServs | SitesCategoryServiceAgent.java * WebServices data for Xpages */ import lotus.domino.Database; import lotus.domino.Document; import lotus.domino.NotesException; import lotus.domino.Session; import lotus.domino.View; import lotus.domino.WebServiceBase; /** * @author Dököll Solutions, Inc. * @version 2013.09.22.5.40.AM * */ public class SitesCategoryServiceAgent { private Session session; private Database database; private View view; private Document document; public SitesCategoryServiceAgent() throws NotesException { session = WebServiceBase.getCurrentSession(); // grab database from session obtained database = session.getDatabase("", "sitefindermobile.nsf"); System.out.println("database loaded from session..." + database); // grab view from database view = database.getView("SiteList"); System.out.println("view obtained from database..." + view); } //perform search public String getSiteCategory(String SiteName) { System.out.println("declare variable to load search results.."); String SiteCategory = ""; try { //search view based on first column (Key) System.out.println("view column search from database..."); System.out.println("using getDocumentByKey..."); document = view.getDocumentByKey(SiteName); if (document == null) { //alert user where no site are found SiteCategory = "Search results for specific site type returned null"; System.out.println("view obtained from database, but no sites..." + SiteCategory); } else { //load site to user where site are found SiteCategory = document.getItemValueString("Type"); System.out.println("view obtained, site Found..." + SiteCategory); if (SiteCategory.equalsIgnoreCase("")) { //alert user where key retrieve null for Type SiteCategory = "check view column, Type is empty..."; System.out.println("check view, column empty..." + SiteCategory); } } } catch (NotesException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return SiteCategory; } } Copy and Paste JavaAgent to invoke WebService: Create a new JavaAgent, copy and paste the following over the generated code. You will be using this JavaAgent to invoke the WebService consumer and grab documents from your view. You will also add the snippet you checked earlier from the SitesCategoryServiceAgentService.java class. /** * Created: 2013.09.23.5.54.AM * ConsumeSitesCategoryWebServsJavaAgent | JavaAgent.java * WebServices data for Xpages */ import lotus.domino.*; /** * @author Dököll Solutions, Inc. * @version 2013.09.23.5.54.AM * */ public class JavaAgent extends AgentBase { public void NotesMain() { try { //Locate the WebService code to perform the search, aided by sitefindermobile.nsf WSDL //Note: below stub may be different than your version if you named your WebService Agent differently //grab below stub from the YourWebServiceAgentNameService (for this exercise ours is named 'SitesCategoryServiceAgentService' //code that can be found among the four Java classes generated when creating the WebService consumer SitesCategoryServiceAgent stub = new SitesCategoryServiceAgentServiceLocator().getDomino(); //do something with the result of your search //example show the value of getSiteCategory method in an Xpages form System.out.println(stub.getSiteCategory("Dököll Solutions, Inc.")); } catch(Exception e) { e.printStackTrace(); } } }