IBM Connect 2014: BP 206 - Be Open - Use Web Services and REST in XPages Applications

>>Author:  Bernd Hort
>>Ort:     Orlando, FL
URL: http://www.assono.de/blog/d6plinks/IBM-Connect-2014-BP206

Category: IBM Connect, Lotusphere, Konferenzen, XPages, Web Service, REST

IBM Connect 2014

Sitting in the closing session of IBM Connect 2014. So there is only one more thing to do before enjoying the show. Keeping my promise to upload the presentation and the sample application from my session.

BP 206 - Be Open - Use Web Services and REST in XPages Applications


#1 Thanks for sharing. Much appreciated!

How do you think the conference was, overall?
Gravatar Image
#2 I think IBM is daring to step into new areas with big data en kenexa services, nothing wrong with a bit of daring.

about Notes I am not sure how to place the announcements. IBM broadcast it is a steady mail platform. not sure how they think of it as a application platform?
Gravatar Image
#3 The conference had a lot of great sessions, specially about XPages. Yes, the number of technical sessions was lower than the years before. But frankly today I enjoy the discussions between the sessions more. Thats were I get my ideas. Gravatar Image
#4 Hi, I am unable to unzip the database file.. Can you please check it out, and re-upload a working file ? Gravatar Image
#5 Hi Chris,

I've just checked the zip archive. It seems to be correct (7-Zip told me so). Could you try again?

Gravatar Image
#6 Hi Tom, I re-checked, I get the following alert when I try to extract,

Windows cannot open the folder.

The Compressed (zipped) Folder 'c:\Temp\BP206.zip' is invalid.


This is through the default Windows extraction, not through Winzip or any other software..
Gravatar Image
#7 I am not able to unzip the file either... Emoticon
Please try to upload a new version of the zip-file Emoticon
Gravatar Image
#8 Hi again!
I downloaded 7-Zip and then it extracted without problems Emoticon
Gravatar Image
#9 Hi Chris,

I repacked the demo database and validated that it now can be opened with Windows Explorer.

Thank you for your comments.
Gravatar Image
#10 Hi, thanks for posting this. There really is very little information about how to use REST with XPages programmatically as opposed to Drag and Drop.

I can get the demo to run great as a local replica but when I put it on a server ( 9.01 and 8.5.3 ) I get security errors.

For the RestClient page I get the following even though I have updated the java.pol file as suggested :
[15FC:000C-16B8] 15/07/2014 11:19:51 HTTP JVM: java.security.AccessControlException: Access denied (java.lang.RuntimePermission getClassLoader)

For the Home page I get the following error

Error while executing JavaScript computed expression
Script interpreter error, line=1, col=40: Error calling method 'getSessions()' on java class 'de.assono.connect2014.WebServiceClient'
XML reader error: javax.xml.stream.XMLStreamException: Zwischen "SYSTEM" und der System-ID ist ein Leerzeichen erforderlich.
Zwischen "SYSTEM" und der System-ID ist ein Leerzeichen erforderlich

I have seen a few posts that talk about needing public access for agents as a solution for this :

{ Link }

{ Link }

I am not sure if these are connected.

Is any of this familiar ?

Thanks, Sean
Gravatar Image
#11 I got it to work but only by using grant {
permission java.security.AllPermission;
}; on the dev server

Gravatar Image
#12 Hi, on slide 17 it says "If the RESTful Web Service supports XML" . Does this literally mean if it returns the data in an XML format or is it more subtle than that ? Thanks, Sean Gravatar Image
#13 While establishing the connection to the REST Web Service you can specify which media type you would prefer. The following code says

return service.path("sessions").accept(MediaType.TEXT_XML).get(Session[].class);

you would prefer XML.
But the REST Web Service Provider can decide whether he wants to return the data in XML or any other format.
Supporting JSON and XML as a media type simply means doubling the effort. That is why some companies offer only one of both.
Gravatar Image
#14 Hello Bernd,

thanks for taking the time to reply.

I thought that this might be the case but what confused me was that your code still ran when I used a different rest service from JIRA and the data appears to be in a json format rather than xml ( i.e. with "<" and ">" - I have pasted an example from console print statements below - I am not super experienced with JSON so maybe I am confusing something.

Your code ( Session.java ) has @XmlRootElements and import javax.xml.bind.annotation.XmlRootElement but still works with what seems to be non xml data.

I guess it is slide 17 that is confusing me

"If the RESTful Web Service supports XML Jersey just uses Java Architecture for XML Binding -
JAXB to map the XML to Java classes"

If there was another sentence "If the RESTful Web Service does not supports XML then ......" what would it be ?

I do REALLY appreciate your time. There are so many people that say REST is the way forward and yet there are very few concise examples of how to do this with Domino from a programmatic perspective. After 2 days of research I settled on your BP 206 as the best resource out there so thanks for sharing it.

Thanks Sean

console print statements

[11C8:000E-134C] 17/07/2014 09:07:07 HTTP JVM: )","avatarUrls":{"16x16":"{ Link }
[11C8:000E-134C] 17/07/2014 09:07:07 HTTP JVM: projectavatar?size=medium&pid=11103&avatarId=10011","48x48":"{ Link }
[11C8:000E-134C] 17/07/2014 09:07:07 HTTP JVM: ","name":"FoCul"}},{"self":"{ Link } Account Management","avatarUrls":{"16x16":"{ Link }
Gravatar Image
#15 Hi Sean,

from your print statements it seams that the REST Web Service returns JSON.

Which is perfectly fine, if you also use Jackson as a JSON-To-Object-Mapper.

What might be a little confusing is that Jackson uses the same Java annotation as JAXB.
That's why the Session.java class has @XMLRootElements.

Does your code for consuming the REST Web Service contains
import org.codehaus.jackson.map.ObjectMapper;
and something like
String json = service.path("Sessions").accept(MediaType.APPLICATION_JSON).get(String.class);

ObjectMapper mapper = new ObjectMapper();
return mapper.readValue(json, Session[].class);
These lines above are for mapping JSON to objects.

If you have XML you could simply call
return service.path("sessions").accept(MediaType.TEXT_XML).get(Session[].class);
Gravatar Image

Post A Comment




Deutsche RSS-Feeds (German)

Custom Button Custom Button

English RSS feeds

Custom Button Custom Button