Skip to main content
This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal

HCL Notes/Domino 8.5 Forum (includes Notes Traveler)

HCL Notes/Domino 8.5 Forum (includes Notes Traveler)

Previous Next

Ok...here's what I've got...

...I have a database where I'm testing all this stuff, it's really rough round the edges, purely proof of concept stuff. This is a mix mash of ideas by a whole laod of people way smarter than me: Tim Tripcony, Chris Toohey, Matt White, Stephan Wissel, etc.

I have a bigger update at end of this post, but for first part: calling a web service via javascript.

Set up your web service, either in LotusScript or Java, I'm doing mine in java (My goal is to get to backing beans, more on that in a minute). Do a really simnple web service: getUserName() beantest(). Test your web service...I use SOAPUi and make web service avaiable for public access, once tested, I take public access off. Next I get my javascript (not SSJS) bit sorted:

soapMessage = '';
soapMessage+='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">';
soapMessage+='<soapenv:Header/>';
soapMessage+='<soapenv:Body/>';
soapMessage+='</soapenv:Envelope>';

// If your web service has input, then the message looks something like this, where I'm passing in "xxxx" as a parameter.
/*
soapMessage+='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:DefaultNamespace">';
soapMessage+='<soapenv:Header/>';
soapMessage+='<soapenv:Body>';
soapMessage+='<urn:TXT>xxxx</urn:TXT>';
soapMessage+='</soapenv:Body>';
soapMessage+='</soapenv:Envelope>';
*/


if(window.XMLHttpRequest) {
httpRequest=new XMLHttpRequest();
} else if (window.ActiveXObject) {
httpRequest=new ActiveXObject("Microsoft.XMLHTTP");
}

var url = "http://urltoyourdatabase.nsf/EchoTestJava2?OpenWebService";
httpRequest.open("POST",url,true);
if (httpRequest.overrideMimeType) {
httpRequest.overrideMimeType("text/xml");
}
httpRequest.onreadystatechange=populateDiv;

httpRequest.setRequestHeader("Man", url + " HTTP/1.1")
httpRequest.setRequestHeader("MessageType", "CALL");
httpRequest.setRequestHeader("Content-Type", "text/xml");

// This is the line you change to match whatever "actions" your webservice has.
httpRequest.setRequestHeader("SOAPAction", "beantest");

httpRequest.send(soapMessage);
valTimeout=setTimeout("timeout(httpRequest);",120000);

function populateDiv(){
try {
if(httpRequest.readyState==4) {
if(httpRequest.status==200) {
clearTimeout(valTimeout);

var text = httpRequest.responseText;
console.debug("Creata XML dom");
var dom = dojox.xml.parser.parse(text);
var docNode = dom.documentElement;
var html = "";

var returnElement = docNode;

for (var i = 0; i < returnElement.childNodes.length; i++) {
html +="~~~" +
dojox.xml.parser.textContent(returnElement.childNodes[i]);
}


var resultDiv=document.getElementById("resultDiv");
resultDiv.value = html;
}
}
} catch(e) {
alert("Error!"+e.description);
}
}


If you use the passing in parameter "xxxx" envelope above, and you are using FireBug, you will see a response something along the lines of below, for test I just return the text I sent in, the server name, filepath and the time. I am writing results to a "resultDiv"
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<soapenv:Body><ns0:ECHOReturn xmlns:ns0="urn:DefaultNamespace">xxxx UserName: CN=gsxr/O=bikes, Server: CN=gsxr/O=bikes, FilePath: Projects\dev\test.nsf, Time: 04/08/2010 20:55:47</ns0:ECHOReturn></soapenv:Body>
</soapenv:Envelope>

OK, so that all works. Any legacy LotusScript or Java I have in Script Libraries, I can expose all that via webservice and get to it from client side javascript...nice.

...but what I really want is to be able to get to backing beans from web service. For more on backing beans see: http://www.mindoo.com/web/blog.nsf/dx/16.07.2009095816KLEBCY.htm there is a series of articles (this guy has skills waaaayyyy beyond me). The backing bean stuff is great. Otherwise I write java code in backing bean, but then have to copy\ paste to a script library so the web service can access it. Now if anyone knows how to get from web service to backing bean, speak up now :-) But in the project I am involved with, they want complete separation, all done by web services, so how do I get to backing beans...well I went back to this article: http://www.wissel.net/blog/d6plinks/SHWL-7MGFBN, (another great blogger), I had a thought: from client side JS, call an action on my web service GetSomeDataFromBackingBean(), the java code in that opens a url connection to my xpagebeaninterface.xsp, which (since an xpage can get to the backing beans) does whatever action in my backing bean, then writes back, I read the xml\ JSON response from that, and pass back from web service. Result!!! It's late, I've one glass of wine too many, but my url connection is getting login page, I think I need to POST a login before calling my benainterface.xsp, but I think this could do it. I am sooo close...I'm going on holiday for the next 10 days, but will dabble with this and post any results...I really want to know thew answer!!!


Feedback response number WEBB87ZRWC created by ~Evelyn Brealitakoi on 08/04/2010

XPages, Beans, Web Services and Jav... (~Holly Quetfook... 3.Aug.10)
. . Yes, we are interested, post the co... (~Tate Xantumize... 4.Aug.10)
. . . . Ok...here's what I've got... (~Holly Quetfook... 4.Aug.10)




Printer-friendly

Search this forum

Member Tools


RSS Feeds

 RSS feedsRSS
All forum posts RSS
All main topics RSS