logo

The Case For Using a Web Service Wrongly

The jury's out on whether I am using a Web Service correctly. Although what has been discussed has confirmed that, as I suspected, strictly speaking, what I am proposing (consuming a Web Service from within the same Domino application) isn't using them like you're supposed to.

Why Use a Web Service?

To prove how simple it can make life as a developer to use a Web Service I'll work backwards from my Flex application to the Web Service in the Notes database in which the Flex app lives.

Remember I showed you the Accounts Flex app and mentioned that I'd used a Web Service to provide the functionality behind the new flag column I added to the "view":

ScreenShot003

The flag icon lets you toggle the value of a field called "Flagged" in the back-end document from "1" to "0".

In Flex the code for the icon looks like this:

ScreenShot002

It's an image, as you can see. It has an "on click" event defined. When you click it the Flag method of the Web Service (which has been given the name "serverActions" in Flex) is called and the row's document's UNID is passed along with a boolean to tell the server whether to toggle on or off.

That's the beauty of it. It might be immediately apparent but what you see above is so much simpler than the other ways of doing this.

Once the Web Service is defined in Flex I can add a new function to it in Domino Designer and strictly define the number and type of parameters it should accept. I can then switch straight to Flex and call the function from there. No need to add a new HTTPService (URL to pass the new function call to) and/or add functions inside Flex to handle the passing/receiving of the data.

In short it just makes things simpler. It doesn't offer much else really. Whether there's a performance hit, I don't know. Not that I've noticed. Have a go at toggling the flags in the Accounts app and see what you think. It's as responsive as I'd expect it to be of any internet-based app.

What's The Web Service Look Like?

Here's the backend LotusScript in the Web Service:

ScreenShot004

All very straight-forward. It's probably a bad example as there are probably easier ways to toggle the value of a single field, but imagine you want some other complex business logic to take place at the same time. You can contain it all within one design element.

Summary

Not sure how to summarise this. Despite three days on the topic I don't feel like there's any closure. I still feel like I'm doing wrong. But hey, does it really matter. As long as I always do it a way that means it remains secure then I don't see the problem. It makes development easier and that has to be a good thing?

Comments

  1. Personally, as a current Flex developer and former Domino developer, I think that's a perfectly acceptable way of integrating Flex and Domino given the options.

    The most efficient way is AMF (binary remoting protocol), but I don't know if there is any way to do AMF with Domino these days - if there is it's probably Java based though.

    A web service is the most flexible in that just about anything can talk to web services these days and you have a standard for discovery and introspection (WSDL).

    As you say, as long as you ensure security - so that someone working out what the web service calls are can't just make changes willy nilly - then I say web services are your best bet.

    Anyway, that's my 2c.

  2. Jake I agree with Marcin.

    After all technically its not the same database, the back end logic is completely seperate from the UI.

    And as a bonus you can call the same logic from within the Notes Client (v8 and above).

    Some of us still develop for the client as well ;-)

  3. Jake, I would stop worrying whether you are using it right or not. You're using a well formed, nicely abstracted bit of code that, as Mark points out, can be used elsewhere. The only time I would worry if I'm doing it exactly right is if you find yourself in a conversation with a system architect who insists on strictly formal architecture. Otherwise, all the tools in the box are fair game any time it makes sense to use them. So fret not, and code ye onward!

    • avatar
    • Jeromy Glenn
    • Tue 3 May 2011 11:58 AM

    hi Jake,

    As a beginner of Domino developer, I am very interesting at your post and that's exactly something I am looking for, as I need a solution to solve out the data transfer between my two systems with web Services. Can you post out or send the account.nsf to me for reference? thank you a lot!

    Have a good day

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:


About This Page

Written by Jake Howlett on Fri 3 Apr 2009

Share This Page

# ( ) '

Comments

The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »

More Content