I am trying to prove Domino will consume web services from external sources using Java.
To do a quick test, I made one app: FAQs. It has a simple form with a Key, Question and Answer.
I added a web service provider (java) as follows:
import java.util.Vector;
import lotus.domino.*;
import lotus.domino.types.*;
public class ListFAQsByAppWS{
// This is a template implementation class for your web service. It
// becomes extraneous if you import a WSDL document. Consumers of this
// web service can call any public method in the implementation class.
//
// To obtain a Session object use this code:
// Session s = WebServiceBase.getCurrentSession();
private Session session;
private AgentContext ac;
private Database db;
private View view;
private DocumentCollection dc;
private Document doc;
private Vector faqs = new Vector();
// Initialize our context and gain access to the view we need
public ListFAQsByAppWS() throws NotesException {
session = WebServiceBase.getCurrentSession();
ac = session.getAgentContext();
db = ac.getCurrentDatabase();
view = db.getView("ByAppKey");
}
// Use the appKey param to lookup all FAQs for the specified app
public java.lang.String getFAQsByApp(
java.lang.String appKey) {
StringBuffer faq = new StringBuffer();
try {
dc = view.getAllDocumentsByKey(appKey);
doc = dc.getFirstDocument();
if (doc != null) {
faq.append(doc.getItemValueString("Question"));
faq.append(doc.getItemValueString(" "));
faq.append(doc.getItemValueString("Answer"));
faqs.addElement(faq.toString());
}
} catch( Exception e ) {
e.printStackTrace();
}
return faqs.toString();
}
}
In Eclipse, using the Web Service Explorer, I can test the web service and it works fine.
I created a second Domino app, created a Web Service Consumer and pointed it to the web service provider. All good.
Then I created an agent (in lotusscript for quick test) to call the method:
Option Public
Option Declare
Use “FAQsByAppWSConsumer”
Sub Initialize()
Dim faqs As New Listfaqsbyappws
Dim key As String
Dim faqEntries As Variant
key = "Teams"
faqEntries = faqs.Getfaqsbyapp(key)
MessageBox "First FAQ: " + faqEntries(0)
End Sub
It compiles just fine. However when I run it in the client (from action menu) I get an error that the web service method getFAQsByApp is not found (404).
The web service provider is available to public users (on a dev server internal).
What could I be missing? I need to show this to my team tomorrow, and can’t get even a simple example to work!
Thanks,
Ginni