XPages, Beans, Web Services and Javascript

About to XPage a Notes client application. We currently have lots of logic in LotusScript libraries.

The desired goal is to decouple the web Ui from the business logic and data layers, accessing the data layer via javascript and web services. I am not sure if this is possible on Domino.

My main question is: if user accesses an application on Server A via HTTP, can a web service on Server A be called via javascript? I know you can not call a web service via SSJS on same server.

Now we could develop a web service api independantly, but if we are putting the effort into that, it would be nice to use it in Domino http.

I have a feeling it has to do with the way Domino handles urls: → IBM Lotus Notes Domino REST Web Services via XPage XAgents - Part 1 | dominoGuru.com Chris’s article, who I greatly respect…(if you find this question Chris, would be very interested in your response), is using agents\xpage, which would work for the domino side, but we still wouldn’t have a web service api, for other potential “clients”, although they could use the agent\ xpage.

Other thoughts: Ideally I would like to start migrating business logic to a backing bean (as described here: Mindoo - XPages series #4: Backing Bean Management with XPages), which has many benefits for us. The obstacles I see are: any providor web services we create, will not have access to the bean code, we could move the java code to Script Libraries, but now we lose benefits of backing beans, and we have to maintain code in 2 places. Also backing bean code is “isolated” from any other logic that has already been written.

There doesn’t seem to be any way to link all these pieces together…?

All comments, suggestions, etc. would be gratefully accepted.

Subject: What about calling the Web Service via a Java URLConnection?

Sorry Nick, just seeing this post now.

You could create a Java Script Library that uses a Java-based URLConnection call to your Web Services:

Then use the method discussed here to get it SSJS-accessible:

… which I see (at least Nick) you’ve already seen (you’re the first comment).

But using this technique, you’ll be able to communicate with ANY Web Service, Domino or external, and read/write content over an HTTP Request via SSJS!

HTH,

-Chris

Subject: If the bean interacts with Domino…

  • Why can’t it be incorporated into a web service? If nothing else link the bean to the web service and have the XPage use that natively instead of the bean itself. I’d think both would be doable, though.

Or am I missing something?..