Friday, February 15, 2008

Java, XPath, XML and Facebook

PeopleSoft's Integration Broker and Web Services provide an excellent framework for web services integration. But what if your PeopleSoft system needs synchronous access to another system that doesn't publish web services? For example, let's say you need to communicate with a system like Facebook that has a Java client library (yes, Facebook has a REST-based API, but using the existing Java client is much easier than creating all of the messages, handlers, and Facebook specific publishing logic). Even though we can call Java directly from PeopleCode, the Facebook methods return a value of type org.w3c.dom.Document. Since this return value is a Java object, not a PeopleCode XmlDoc, you cannot use the standard PeopleCode Node methods to extract values from the resultant document. In the absence of an additional client library, we would have to write DOM traversal code to select and concatenate the text node values contained in the Facebook response elements. Fortunately, the PeopleSoft application server installation includes the Xalan XML processor. The Xalan client library includes the org.apache.xpath.XPathAPI class that can be used to select values from a Java DOM Document similar to the XmlDoc.FindNode method. Here is an example of using the XPathAPI in PeopleCode to extract the name of the first friend from a Facebook friends query:

Local JavaObject &results = &fbClient.fql_query("SELECT uid, name, status FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = '" | &uid | "')");
Local JavaObject &xpath = GetJavaClass("org.apache.xpath.XPathAPI");
Local string &name = &xpath.selectNodeList(&results, "/fql_query_response/user[1]/name/text()");


Stephen said...

Hi Jim...I am a Learning Consultant and my company uses Peoplesoft HRMS...I am researching the use of Facebook as a learning delivery vehicle for our geographically diverse workforce...Can Peoplesoft communicate employee information to Facebook and set up personal profiles for employees who do not already have a Facebook profile?...Thanks for your help!

Stephen Cooles
Sr. Learning Consultant
Carlson Restaurants Worldwide

Jim Marion said...

@Stephen, good question. To create Facebook users, Facebook would need to expose an API for creating users. I am not aware of one. Generally speaking, free sites like Facebook, GMail, etc, don't allow automated account creation to avoid spam and other malicious uses.

If you have a Facebook account, can you use PeopleSoft to update HR data? Absolutely. Just use the Facebook API. I prefer FQL. You can find the Facebook API at

blain said...


We are in the discovery stages Integration Broker. What we need to do is setup asynchronous messaging between our PeopleSoft 8.9 (tools 8.48.9) HRMS and a third party system. My research has lead me to believe that I use Nonrowset-based messages and use the XMLDoc and Operation classes to accomplish this. My problem...I can't find any examples of how to set these messages up. Can you give some code examples to accomplish sending a message to a third party?

Thank you

Jim Marion said...

@blain, I assume your third party has an HTTP listener? If so, then you create a new node for your third party system and set it's connector to HTTPTARGET. Set the HTTP properties accordingly. When you publish a message from a PeopleSoft component, the integration broker will use the HTTPTARGET to communicate with the third party.

What version of PeopleTools are you using? If you are using PT 8.48 or higher, create a service, service operation, and routing rules, etc. If you are using PT 8.47 or lower, use node transactions to specify which messages a node should receive.

You can allow PeopleSoft to publish a structured message and then use a transform program registered on the PT 8.48 routing or PT 8.47 relationship. A transform program uses XSL or PeopleCode or both to change the shape of an XML document.

I know this isn't a full example, but hopefully it is enough to get you started. The Oracle University PeopleSoft Integration Tools class describes this in detail.

blain said...

Thanks Jim. I would love go the University lack of funds like everyone else.

Jim Marion said...

@Blain, right, sorry. You are at a serious disadvantage for trying to implement integration without the integration tools class. I know my response gives you some pointers, but certainly doesn't lay out the full solution. Hopefully browsing through itttoolbox and otn forums will give you enough info to piece this together.

Nazly said...

Hi Jim,

I am working in consulting Peoplesoft Campus Solutions; I would like if you know campus has integration with facebook or another social network that Oracle had Developed. Why? For xample, an any student wants to view his grades, advance, schedule or dats from his instructor.

Thanks so much for any help that you can give me.

Note: Sorry, my English is not very good.

Bibiana Córdoba

Jim Marion said...

@Nazly, I'm not aware of anything delivered. The current Facebook JavaScript API is fairly easy to use from PeopleSoft.

Praveen said...

Hi Jim,

We are facing some issue like, whenever users signing in to Peoplesoft, the left hand menu is not expanded/displaying. They can either refresh the page, or use the “-“ box to minimize and then maximize. The menu then appears correctly.

Please give me some idea why it is happening like this.

Thanks in Advance.


Jim Marion said...

@Praveen, no idea. I suggest you log a support request.

Steve said...

Hi Jim,

I'm a PeopleSoft CRM developer, and looking into the possibility of sending Facebook friend requests from CRM. This would have to include searching for names, etc, but sending friend request from CRM once found.

Let me know if, from your experience with Facebook APIs, this would be a fairly straightforward solution to attempt.

Thanks for your time and comments

Jim Marion said...

@Steve, when I wrote this post, Facebook had a very different API. Now when I integrate with Facebook I first look at the Facebook Social Plugins. If one of those meets my needs, then I use the Pagelet Wizard to create a pagelet. The Pagelet design is pretty much the same as outlined in my post on Google Gadgets. Otherwise, I have to resort to the Facebook Graph API.

Kerstin said...

Hi Jim! I am looking into launching Facebook Collect and wondering how I can get new data from Facebook to PeopleSoft, bypassing ExactTarget. Is it possible? Thanks!

Jim Marion said...

@Kerstin, I am not familiar with ExactTarget. Is it the marketing solution described here? Sounds like a very good integration for PeopleSoft Applications.

Now, how to bypass? Using the Graph API it is possible to collect a good amount of data about group members, etc. I don't have a current example. It is extremely critical, however to make sure you understand Facebook's terms of use. Last time I read them, they said you could access just about any information, you just couldn't store it.

Kerstin said...

Yes, that's it. Thanks, I appreciate it.

Thathagai said...

Thanks for providing a way to consume REST formatted data but is there a way to provide data in RESTful style from peopelsoft

Jim Marion said...

@Thathagai, The RVP for PeopleTools 8.52 says REST will be in 8.52. This means that Full REST is not possible with just plain PeopleTools (verbs, HTTP status codes). If you are not planning an 8.52 upgrade, then your REST plans should consider how much REST you need. Do you just need HTTP URL's? If so, then a call into PeopleSoft could use the HTTP Listening Connector with all the query string parameters, etc (look for Setting Credentials in Query Strings). Your PeopleSoft synchronous service operation will have an OnRequest handler to return results. If you use an Any to Local routing, then the only required query string parameter is the Operation parameter. Your PeopleCode service operation handler could return XML, JSON, or anything. This is actually how I do a fair amount of my Ajax.

Jim Marion said...

@Thathagai, I just posted this on Rest-like services.

Thathagai said...

Thanks Jim! The post is quiet helpful!

Rasika said...

Hi Jim,

I would like to know how can we integrate facebook with peoplesoft.
And what all steps I need to follow for the same

Jim Marion said...

@Rasika, Facebook has changed a lot since I posted this 4 years ago. Unfortunately, I don't have current example.

Mohit Pandey said...

Hi Jim,
In my xml parent and child records have the same fields but different values. In xml publisher, at every place it's showing only parent record values not the child one. Please let me know if we can give record.field or can use some alias for fields in XML Publisher.

Jim Marion said...

@Mohit, I have no experience with XML Publisher. I suggest you post your question on the PeopleSoft Business Intelligence OTN Forum.