Calling web services from XPages the missing part

I had an XPage project where I needed to call some web services to get some information and after reading on different blogs my hopes of getting this to work was almost null. But sometimes knowing your history helps and I remembered how I started to create subforms using dxl for several years ago and that almost everything is stored with in the design note.

So I started to think, does the built in web service consumer create the code inside the design element and yes it did. Great!

Check out my Notes in 9 video here

or continue to read the post

Is there any common things between between this and XPages, Yes. Java! But there is a problem they work in different jvm:s. But when I looked closer to a web services consumer with generated java code, there where 3 jar files attached to the design note. One with the source, one with the precompiled java code and one with the configuration settings.

Let’s export the java code and try, but there isn’t any way to export it. So I created a Lotusscript agent that will export the consumer code, it can be found at xsnippet.openntf.org or here

Import that code into an agent and place the agent inside your database with the created java web service consumer. Run the agent, enter a valid path for the export.

There is only one thing that you need to check when the consumer is created. The consumer java code must be in a package, if not the XPage code will not work or at least I haven’t found a way.

Now Import the two jar files created, in the XPage jar section, or if you are using 8.5.x add the jar files using the package explorer.

Next step: Create a java file that will use the web service code.

And call the code from the XPage.

No modifying java.policy, No special java command line things the only thing is that you must be able to create the java web service consumer and some web services doesn’t work but that I can live with.

This is of course nothing supported by IBM but I will try to convince IBM to build in the export/import action so my agent is unnecessary.

The sample database can be found here

The databases is using free webservices from http://www.restfulwebservices.net/ where I use the soap version instead for the rest service that is not working with the webservice consumer in Domino.

i.e. the stock quote WDSL file can be found at http://www.restfulwebservices.net/rest/StockQuoteService.svc?wsdl and to be able to use this with Domino I change the url to

http://www.restfulwebservices.net/wcf/StockQuoteService.svc?wsdl to get the soap version of the webservice.

If you have any questions feel free to send me a comment or use the contact link above

5 Comments.

  1. Great work! Very easy to understand and implement. I have one question though, what’s the benefit of using this approach instead of the consumer and a Java agent? Is it more efficient to use a Java agent then Java because of the jvm?

    • Fredrik Norling Fredrik Norling

      I think this way you can transfer data between the webservice and XPage code easier. If you are using the agent approach you need to store the data inside a notesdocument.

  2. That is cool. Thanks for sharing.

    • Fredrik Norling Fredrik Norling

      Great that you liked it, checkout my blog more cool stuff coming soon :razz: