Using REST (representational state transfer) with Cache...?

1,113 views
Skip to first unread message

JJ

unread,
Jul 9, 2013, 7:29:16 PM7/9/13
to intersystems...@googlegroups.com
Hi all,
 
I just finished doing some web service programming, which is operational and working!  Yay for me. This is all very new to me.  That was using provided WSDL files, which I was able to load into classes via Studio and the SOAP wizard.
 
I now have another API project which has landed in my lap and know very little about it just yet.  But I've been told it's using REST vs. SOAP.  I get the general idea, but it doesn't seem like there will be any WSDL type files to load, which was a pretty good starting point for the prior project.
 
I can't seem to find any documentation within Cache help either referring to REST.  Just SOAP.  Can any one direct me to where I might start?  I will have more info soon once the documentation is sent to me...but just thought I'd check with all you gurus out there for any newbie tips and/or help.
 
Many thanks!  JJ

jayne...@gmail.com

unread,
Aug 23, 2013, 1:33:18 PM8/23/13
to intersystems...@googlegroups.com
%CSP.REST.DocServer ( or if on newer versions of cache ) Samples: REST.DocServer

Gives example usage

JJ

unread,
Aug 28, 2013, 10:54:58 AM8/28/13
to intersystems...@googlegroups.com, jayne...@gmail.com
Thanks.  Got it going but this will be helpful for future ref.  JJ

Mike Kadow

unread,
Aug 29, 2013, 8:47:26 AM8/29/13
to intersystems...@googlegroups.com
JJ - I hear that REST will be supported Cache 2013.2
 
-Mike
 

Date: Wed, 28 Aug 2013 07:54:58 -0700
From: jeffe...@hotmail.com
To: intersystems...@googlegroups.com
CC: jayne...@gmail.com
Subject: [Caché] Re: Using REST (representational state transfer) with Cache...?
--
--
Caché, Ensemble, DeepSee
 
---
You received this message because you are subscribed to the Google Groups "Caché, Ensemble, DeepSee" group.
To unsubscribe from this group and stop receiving emails from it, send an email to intersystems-publi...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Tom Fitzgibbon

unread,
Aug 29, 2013, 9:19:17 AM8/29/13
to intersystems...@googlegroups.com
ISC Cache 2013.2.0.427 beta release has below in the release notes, but I haven't tried REST in the release yet.

This version introduces support for handling REST requests, routing them to a given namespace, and processing them. This support is at the level of the CSP Gateway.

This feature is predicated on providing a Web application that routes all requests to a given handler class that, based on a URL mapping facility, then dispatches the calls to the correct class and method implementation. With this feature, Caché can now handle any REST interface; for data transport, Caché supports XML or JSON.

Not available in VMS.

Tom Fitzgibbon | Multidata | 212-967-6700 x537

jnttjffrsn

unread,
Aug 29, 2013, 2:23:36 PM8/29/13
to intersystems...@googlegroups.com

Good to know. Thx again. JJ

You received this message because you are subscribed to a topic in the Google Groups "Caché, Ensemble, DeepSee" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/intersystems-public-cache/_g_k38y-qug/unsubscribe.
To unsubscribe from this group and all its topics, send an email to intersystems-publi...@googlegroups.com.

Adam Lees

unread,
Aug 30, 2013, 6:33:00 AM8/30/13
to intersystems...@googlegroups.com
I don't know what extra functionality the recently-introduced explicit REST support brings to the table, but you can easily do REST web services by subclassing %CSP.Page and overriding the OnPage and OnPreHTTP methods....

Class MyRESTService Extends %CSP.Page
{

ClassMethod OnPage() As %Status [ ServerOnly = 1 ]
{

"<html><title>web service</title>"
"<div>"
"message payload here"
"</div></html>"
$$$OK
}

ClassMethod OnPreHTTP() As %Boolean [ ServerOnly = 1 ]
{
Do %response.SetHeader("Content-Type","text/html")
1
}

}

Just set the content type to what your service responds with.  E.g. if plain text instead of html just replace "text/plain" with "text/html" (and get rid of the html tags in the OnPage, just send your response string(s).  Or if it is a JSON service, with "text/json".

As this is inheriting from %CSP.Page, the CSP gateway handles the request/response and you have access to any request parameters within the %request object, and you can also use the normal CSP session persistence mechanisms.


cimmaron

unread,
Jan 22, 2014, 4:01:28 PM1/22/14
to intersystems...@googlegroups.com
Hi Adam,
Can one do POSTs to an external web service from Cache without using CSP? 
I was thinking of using the   %Net.HttpRequest client and just calling a POST method with a JSON string in the request string. Is there really a need for a CSP class?

Thanks

Ron Sweeney

unread,
Jan 23, 2014, 11:11:36 AM1/23/14
to intersystems...@googlegroups.com
Yes,

As far as an example of restful calls to an external web service, I have a solution that shows this out on Github that interacts with the HumanAPI in this fashion:


Direct Class Example Code:


Is that what you are looking for ?

--
Ron Sweeney
Solutions Architect

401 Hall St. SW Maker Space 11
Grand Rapids, MI 49503 USA 


rtweed

unread,
Jan 23, 2014, 12:27:33 PM1/23/14
to intersystems...@googlegroups.com
Alternatively, use the new built-in REST capability of EWD.js:


Rob


Reply all
Reply to author
Forward
0 new messages