8/8/2011 12:00 PM
by
Peter Newhook
InfoPath 2010 introduced the ability to get external data from a “REST Web Service.”’ REST (REpresentational State Transfer) services became the darling of Web 2.0 a few year s back when Facebook exposed their API as a ‘RESTful’ service. Every other major site has since followed suit and we now have the ability to deeply integrate our projects with the social experience.
The exact definition of a RESTful system has become a source of contention among geeks. Proponents of ‘pure’ REST architecture point to Roy Fielding’s 2000 PhD dissertation. They cite things like reuse of HTTP verbs, meaningful headers, stateless protocols and identifiable resources. This group would be shocked at the InfoPath implementation. InfoPath has no idea what a header is, can only make GET requests, and you can return data in any format you want, as long as it’s XML.
I however, ask myself one simple question when deciding if I can call a system RESTful. ‘Can I hook that up to Twitter?’
We begin with a new blank form, and add a REST Web Service from the Data tab.
- search.twitter.com – the base URL that hosts the Search API
- search.rss - this specifies that we want our response formatted as an RSS feed. ATOM and JSON are also available, but ATOM doesn’t have all the fields we need, and InfoPath doesn’t understand JSON.
- ?q=infopath – here we specify what we want to search for in our query sting using the q parameter. We’ve chosen to search for “twitter” by default.
This is neat, but what about if you want to search for something other than ‘twitter’? Users of SOAP web services are familiar with setting a query field in a data source, but REST Web Services are handled a little differently. Start by adding a field at the top of your page named keyword, and put a button under that. Click on the button and a new Control Tools contextual menu will appear. Click on Rules to open the buttons rules pane.
Conclusion:
InfoPath 2010 brought with it the ability to make calls to RESTful web services. However, ’HTTP’ web service would be a better name for this feature as InfoPath doesn’t support most features that make a REST architecture so appealing. Nevertheless, it does open the door to some interesting opportunities. In this article you’ve seen how to use the Twitter search API to pull data from twitter, then design a form to query the service and display tweets using features like the image control.Knowing how to use REST web services in InfoPath enables us to use all kinds of data sources. InfoPath developers are no longer restricted to web services with a valid WSDL files. We can now request any valid XML (and potentially even HTML) and parse the response. Sources with rich, URL based identifiers like SharePoint list oData feeds are among the data sources that are opened up thanks to RESTful web servies.
If you would like to see the full form, please visit http://twinfopath.codeplex.com
No comments:
Post a Comment