Call WebService from Java (SSJS - XPages)

package com.domino.openntf;

import java.util.HashMap;
import java.util.Vector;

import javax.faces.context.FacesContext;
import javax.xml.namespace.QName;

import lotus.domino.Database;
import lotus.domino.Document;
import lotus.domino.Session;

public class WSFake {
	public static String Exec() {
		String designElementName = "com.domino.openntf.WSFake";
		String procedureName = "Exec";
			FacesContext context = FacesContext.getCurrentInstance();
			Session session = (Session) context.getApplication().getVariableResolver().resolveVariable(context, "session");
			HashMap viewScope = (HashMap) context.getApplication().getVariableResolver().resolveVariable(context, "viewScope");
			Database currentDatabase =;
			// Enter WebService URL with ending "?WSDL"
			URL url = new URL("");
			QName qName = new QName("urn:DefaultNamespace", "WSFakeDomino");
			InputVariables inp = new InputVariables();
			WSFakeDomino wsPort = new WSFakeDomino(url, qName);
			WSFake wsService = wsPort.getService();
			// Invoke Web Service
			OutputVariables out = wsService.getExec(inp)
			if (out.getReturnCode() == 0) {
				// No Error
				// Do Something ...
			} else {
				// Error
				// Do Something ...
		} catch (Exception e) {
			// Exception - Hata :" + e.getClass().toString() + " - " + e.getMessage()
		return "OK";

1. Create WSDL Stub Files using wsimport

1.1. Open Command Prompt (Run > cmd)

1.2. write "wsimport -d C:\FakeWSFiles -keep"
"C:\FakeWSFiles -> Stub Files will be stored in this folder"

1.4. If everything is fine, you will see these messages on cmd.

parsing WSDL...
generating code...
compiling code...

2. Open Domino Designer, goto XPages Perspective, Open Your XPages Application and goto Package Explorer

2.1. Create src folder under WebContent\WEB-INF

2.2. Right click on src and click on Build Path > Use as Source Folder menu.

2.3. Goto C:\FakeWSFiles folder and open *.java file in notepad and copy package name.

2.4. Right click on WebContent\WEB-INF\src folder and New > Other > Java (Package)

2.5. Paste package name on next screen (Name field)

2.6. Click on Finish.

2.7. Goto C:\FakeWSFiles folder and copy all *.java files. (Select All *.Java Files and CTRL + C)

2.8. Select your Package under WebContent\WEB-INF\src and click CTRL + V

3. Now, all Java files is copied under your package.

4. Create another Class and write your own code inspired by this sample code.


5. Add grant for related class at Domino JVM Security file

Open java.policy file from ...\IBM\Lotus\Domino\jvm\lib\security
Append grant string after “// Notes java code gets all permissions”
grant {
permission java.lang.RuntimePermission "setContextClassLoader";
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
grant {
tell http q
load http

// *******************
USAGE in SSJS under Button (Server Options : Full Update) : com.domino.openntf.WSFake.Exec()
// *******************

There are some screenshots in my blog post (

Ferhat Bulut

Ferhat BULUT
May 24, 2012 7:44 PM

All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.

1 comment(s)Login first to comment...
jeniffer homes
(at 03:04 on 22.07.2016)
Wonderful piece of code, works straight out of the box. Thanks!