Hello again! Welcome to the Part 2 - Handling payloads!
If you're new to this series, I'd recommend you to check out the Part 1 - Core concepts. You'll need a basic understanding about how Frontier works before continuing with the Part 2.
Representational state transfer (REST) is a software architectural style that defines a set of constraints to be used for creating Web services. Web services that conform to the REST architectural style, called RESTful Web services (RWS), provide interoperability between computer systems on the Internet. RESTful Web services allow the requesting systems to access and manipulate textual representations of Web resources by using a uniform and predefined set of stateless operations. Other kinds of Web services, such as SOAP Web services, expose their own arbitrary sets of operations.
Hello again! Welcome to the Part 2 - Handling payloads!
If you're new to this series, I'd recommend you to check out the Part 1 - Core concepts. You'll need a basic understanding about how Frontier works before continuing with the Part 2.
Hello.
The idea of this post is to introduce Frontier: An abstraction layer that allows Rapid REST development.
REQUIREMENTS:
Why?
Have you ever found yourself dealing with repetitive tasks like mounting objects, serializing them and eventually handling multiple errors for multiple cases? Frontier can boost your development by making you focus on what really matters: your application.
Frontier is made to stop you from WRITE'ing by instead forcing your methods to return values.
It's designed to make you code clean, and you'll see the why pretty soon.
This is the Part 1, where you'll learn he basics about how to work with Frontier. That means at the end of this part you should be capable of
creating GET requests without difficulties. Since this also serves as a way to introduce the framework, I'll be calling this part: Core concepts.
Hi
I tried to access one server to another server in Cache Rest Service, I tried
Parameter HandleCorsRequest = 1;
and
<Route Url="/data/:first/:second" Method="GET" Call="GetData" Cors="true"/>
But not working,
Can anyone tell me the solution??
Thanks in advance!!
Hello,
I come from a programming background, but haven't touched ObjectScript before my current job, so please forgive my ignorance.
Within an Ensemble system, I need to post some information to a RESTful web service. I'm just trying to figure out how to create a method which takes a simple message and posts this off to a RESTful web service?
Thanks in advance for any help.
a.k.a.. "The World of Widgets Returns!" or "Paternity leave damages Instructional Series momentum"
In our last lesson, we combined 2 separate classes to appear as the same property. We now have the ability to Update our Widget catalog, but what if we want to Create a Widget? Thankfully, we've already done 90% of what we need, just by implementing Edits
Before we begin, I'd like to mention that I am by no means an Ensemble expert, so take this with a grain of salt and please feel free to offer any suggestions for improvement. That being said, I have enjoyed working with Ensemble and wanted to share the approach I took to poll an external REST API for patient data in the hopes that it might help others with a similar goal.
If you get bored easily and just want to see some code, feel free to jump straight to the example on github. It uses dummy data (for obvious reasons) but the core principles should be the same.
Does anyone send alerts via API / Web Services to an application such at Tivoli or CA Spectrum? If so, can you share what commands you send? e.g. If connection is down or queue depth > 200. Thanks.
Quite a few enhancements have appeared over recent months in QEWD for easing and simplifying the creation of REST-based services. It's now even more slick and powerful, allowing you to very quickly create very high-performance, highly-scalable REST (and Web) services that make use of Cache.
I've therefore updated the training presentation deck (Part 31 on developing REST Services with QEWD). It describes all the new features with worked examples. See:
https://www.slideshare.net/robtweed/ewd-3-training-course-part-31-ewdxp…
Hi,
I am new to coding web services and trying to connect to an API that returns its format in xml or json.
I have a class as follows.. when I run I get back a 6059 in my status - Unable to open TCP/IP socket to server
Can someone help me identify what I am missing? Thanks
Class Common.WebDownload Extends (
Hello,
I have a DB server (ser-app-db) where cache is installed as server.
I have a Web server (ser-app-w) where cache is installed as web server and configured as CSP gateway.
I followed the configuration guide (https://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KE…) and ser-app-w perfectly display the CSP and CLS pages.
But that's not working for my REST service, for exemple with the REST sample:
http://ser-app-db/csp/samples/docserver/request(GET): work and show the request
http://ser-app-w/csp/samples/docserver/request(GET): return a 404.
Hi,
I learning Cache Rest Services and I trying to implement it.
I learned get method in rest services.
I need to know How to get raw data (like json, xml, text....etc.) when we post the rest services?
Thank you
Hello fellow developers,
I am currently in need of a way to serve files dynamically (sending specific replacements for when the requested file doesn't exist, possibly depending on other conditions such as passed parameters).
Hello.
I'm having difficulties trying to figure (if possible) how to create an URL that also matches query parameters.
I tried:
<Route Url="/:namespace/test(\?id\=):id" Method="GET" Call="Test"/>
<Route Url="/:namespace/test?(id)=:id" Method="GET" Call="Test"/>
<Route Url="/:namespace/test?id=:id" Method="GET" Call="Test"/>
But none of these worked.
Is it possible when using %CSP.REST or am I restricted to using route parameters?
Thank you.
EDIT:
Forget about the "id" parameter name. It's a bad sample: normally id are by definition, able to be hierarchically included in the URI.
Hi All,
We have a application currently running on Zen framework, now business wants to use Angular JS as their front-end technology for any future release but they don't want to upgrade the existing the modules which are already there in Zen (as of now).
By now it's a commonplace how to implement a basic REST API in Caché and there is good documentation about it here: REST in Caché
A question that comes up from time to time is:
How can I make a parameter in my REST url optional?
Simply put, is it possible to create a URL map in Caché that maps a URL like this:
http://server/API/object///old
While this might look odd, this is actually a valid URL. You can read the details in RFC3986 section 3.3.
The framework provided by %CSP.Rest actually allows us to create maps that match the above URL.
Hi,
I have a UrlMap like the one below.
What if I have to pass two parameters to QueryResults, how to do configure Url?
Something like Url="/Results/:queryID/:parameter2" ?
Thanks.
Hi everyone,
I have a project which requires the sending of JSON messages to an external service provider using REST. The service provider requires the message contents to be signed.
Their instructions:
I am trying to design a RESTful service that takes a string (with control characters). Does something with that in the logic on the server, then returns a string, which may also have control characters.
Basically the string is a pharmacy claim in a delimited format that uses control characters for those delimiters. The logic on the server will pull the entire claim apart and process it.
I was thinking that a GET method could be uses but I'm used to sending content in JSON format and wondered what other normal RESTful ways there were to do this.
Hello everyone,
I'm doing a REST service for integration between 2 systems. The system that invokes me expects a response object where only one of its attributes changes.
In our last lesson, we implemented a linkage to our WidgetAccessory class, and debugged some errors we encountered along the way. We now have our data being returned by REST, but what if we want to update or add new data to our application?
So far we have only used HTTP GET commands with our REST Services, we now have to implement PUT (which roughly corresponds to an Update) and a POST (which roughly corresponds to a Create. Author's note: there is a lot of writing online about why this statement isn't entirely correct, I'm not going to go into the detail here).
or "Things are going to break"
We left our application over the weekend, secure in the knowledge that it was returning data from our primary persistent class, User.Widget. However, Widgets Direct are the premier supplier of both Widgets AND Widget Accessories, so we should really start working on adding these Accessories to our application.
We should do some housekeeping first though. Our Page Controlller code is currently sitting in the widgetmaster.js file.
I thought REST services is accessing confidential data, so we should follow the authenication rules?
Most frameworks support either REST or WebSockets, and don't make it easy to switch between the two, and/or support both styles of application at the same time. WebSockets offer many advantages over REST, eg:
- most benchmarks show WebSocket messaging to be significantly faster than over HTTP
- you break free of the HTTP Request/Response protocol limitations, allowing the server/back-end to send messages to the browser as and when it wishes, not simply when polled by the browser.
Hi everyone,
This is:
Cache for UNIX (Red Hat Enterprise Linux for x86-64) 2016.2 (Build 736U) Fri Sep 30 2016 12:25:56 EDT
The server is on RedHat Linux while the browser is running on Windows (Firefox).
I am helping a partner build a complex modern HTML5 web application that talks with Caché using REST calls. They have been using %CSP.REST very successfully. Security works great as well.
Some time ago, I had defined the parameter CONVERTINPUTSTREAM = 1 on their %CSP.REST classes and that seemed to work.
What are the differenent format handles the data from Rest services?
Something that shot up the popularity stakes last week was this article on a very interesting initiative: RealWorld:
https://medium.com/@ericsimons/introducing-realworld-6016654d36b5
I decided it would be a good idea to use this as a way of creating an exemplar implementation of a RESTful back-end using QEWD against their published API (https://github.com/gothinkster/realworld/tree/master/api)
The results are here:
https://github.com/robtweed/qewd-conduit
Actually it's the first 3rd-party implementation out of the blocks!
In our last lesson, we added some formatting and validation to our Edit Widget form. So, now we are ready to add the ability to add new Widgets to our application. However, the great Widget Wars have come to an abrupt end, as Widget Direct has purchased its biggest competitor, WorldWideWidgets. In order to maintain some continuity, we need to display their catalog on our new application.
So, we have good news and bad news.
In our last lesson, we added a form to Edit our existing Widgets, and save them back to the server. However, our Form was not well structured and our Save button had no intelligence, and was not fully visible. So today, we will apply some Material components and Angular style to make the form more useful
Let's open EditWidget.csp, and make some changes. First, we want to change the component from an md-card to an md-dialog.
Hi all,
I've a RESP API service in a Business Service to server different methods
I've created the route with the name of the method, each one has been created in lowercase
XData UrlMap [ XMLNamespace = "http://www.intersystems.com/urlmap" ]
{
<Routes>
<Route Url="/user" Method="POST" Call="User"/>
<Route Url="/emailactivation" Method="POST" Call="EmailActivation" />
<Route Url="/login" Method="POST" Call="Login"/>
</Routes>
}I heed to his a callback method after all REST call. I have already found a method to call before REST call, but after eludes me. Here's the code:
Class Test.REST Extends %CSP.REST
{
XData UrlMap [ XMLNamespace = "http://www.intersystems.com/urlmap" ]
{
<Routes>
<Route Url="/:classname" Method="GET" Call="TEST" Cors="true"/>
</Routes>
}
/// This method Gets called prior to dispatch of the request. Put any common code here
/// that you want to be executed for EVERY request. If pContinue is set to 0, the
/// request will NOT be dispatched according to the UrlMap. If this case it's the
/// responsibility of the user to return a response.
ClassMethod OnPreDispatch(pUrl As %String, pMethod As %String, ByRef pContinue As %Boolean) As %Status
{
set ^CacheTemp.DBG($i(^CacheTemp.DBG)) = "OnPreDispatch"
set pContinue = $$$YES
quit $$$OK
}
ClassMethod TEST(name) As %Status
{
set ^CacheTemp.DBG($i(^CacheTemp.DBG)) = "TEST"
//w 1/0
quit $$$OK
}
/// Issue an '500' error and give some indication as to what occurred
ClassMethod Http500(pE As %Exception.AbstractException) As %Status
{
set ^CacheTemp.DBG($i(^CacheTemp.DBG)) = "Http500"
quit ##super()
}
/// Doesn't work
ClassMethod OnPostHTTP() [ Abstract, ServerOnly = 1 ]
{
set ^CacheTemp.DBG($i(^CacheTemp.DBG)) = "OnPostHTTP"
}
/// Doesn't work
ClassMethod OnPostHyperEvent(class As %String, method As %String) As %Status [ ServerOnly = 1 ]
{
set ^CacheTemp.DBG($i(^CacheTemp.DBG)) = "OnPostHyperEvent"
quit $$$OK
}
}