IBM Support

Can Domino consume a Web service?

Technote (FAQ)


Question

Can the Lotus® Domino® server consume a Web service?

Answer

Domino 7 and earlier versions provide, but do not natively consume, Web services. Functionality to natively consume Web services has been added in Domino 8.0. For more information on this Domino 8 feature, refer to "Creating web service consumers" in the Domino Designer Help.
For Domino 7 and earlier, you can enable Domino to consume Web services by using Java or by using LotusScript with LS2J. A brief example of using a Java agent is provided below.

Consult the following resources for detailed steps and examples to set up Domino to consume Web services:

"Lotus Domino 7 Application Development"
http://www.redbooks.ibm.com/abstracts/redp4102.html

"Domino Web Service Application Development for the IBM eServeriSeries Server"
http://www.redbooks.ibm.com/abstracts/sg246862.html




Example Java agent

NOTE: This is a sample script, provided to illustrate one way to approach this issue. IBM Support will not be able to customize this script for a customer's own configuration.

What follows is a sample Java agent to connect to and send or receive SOAP packets to a Domino server hosting a Web service. To use it, use the Domino Designer client to create an agent with a Runtime Target of None. The Web service that this agent interacts with has only one function: GETNAME. It is in RPC/encoded format. The Web service code is provided here and the WSDL document is attached below.

Public Class Person
Public Function getName() As String
getName = "My Name"
End Function
End Class


import lotus.domino.*;
import java.net.*;
import java.io.*;
import java.util.*;

public class JavaAgent extends AgentBase {
  public void NotesMain() {
    try {
      Session session = getSession();
      AgentContext agentContext = session.getAgentContext();
      //Soap envelope request for GETNAME
      String data = "<SOAP-ENV:Envelope \n" +
"  xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org /soap/envelope/\ "\n" +  
"  xmlns:xsd=\"http://www.w3.org /2001/XMLSchema\ " \n" +  
"  xmlns:xsi=\"http://www.w3.org /2001/XMLSchema-instance\ ">\n" +  
"  <SOAP-ENV:Body>  \n" +
"    <GETNAME>\n" +
"    </GETNAME>  \n" +
"  </SOAP-ENV:Body>  \n" +
"</SOAP-ENV:Envelope>\n";
      //Open URL HTTP connection
      //Enter the name of server, database and web service in the URL below
      URL url = new URL("http://server-name/database-name.nsf/web-service-name ");
      HttpURLConnection conn = (HttpURLConnection) url.openConnection();
      conn.setRequestMethod("POST");
      conn.setAllowUserInteraction(false);
      conn.setDoOutput(true);
      conn.setRequestProperty( "Content-type", "text/xml" );
      conn.setRequestProperty( "Content-length", Integer.toString(data.length()));
      //Push soap envelope over to server
      OutputStream rawOutStream = conn.getOutputStream();
      PrintWriter pw = new PrintWriter(rawOutStream);
      pw.print(data);
      pw.flush();
      pw.close();
      //Receive response from server
      InputStream  rawInStream = conn.getInputStream();
      BufferedReader rdr = new BufferedReader(new InputStreamReader(rawInStream));
      String line;
      String newline = "\n";
      StringBuffer sb = new StringBuffer();
      while ((line = rdr.readLine()) != null) {
            sb.append(line);
            sb.append(newline);
       }
       System.out.println(sb);
     } catch(Exception e) {
e.printStackTrace();
    }
  }
}

Example WSDL code:
wsdl.txt

Document information

More support for: Lotus End of Support Products
Lotus Domino Designer

Software version: 6.5, 7.0

Operating system(s): Windows

Reference #: 1227879

Modified date: 01 November 2007


Translate this page: