What is the use of GateWayScripts in DataPower? - ibm-datapower

Could you please let me know Any useful online resource to learns and implement some scenarios to explore more about it. Thanks.

Datapowers are historically, in order:
XML Tranformation acceleration Devices (that used to be a thing, XSLT was too slow to process)
SSL offloading devices (again, that used to be a thing, same reason)
Web site and Applications Gateways. Both web sites and web services security, concentrated around HTTP and SOAP/XML application layer mechanisms and standards (SSL/TLS, WS-S, SAML, etc.), but also token management, security conversion ... think "super SSO" + application security gateway
More specialized integration tools : Transformation of XML (with XSLT), Transformation to/from non-XML format (like CSV), Database connections, integration patterns (like routing, composing, and a LOT more). Some called the Datapower a lightweight ESB.
More specialized uses : B2B(EDI), JSON processing, REST/JSON support, API Mgmt (when used as deployment point for API Connect)
Notice that all later features needs the former ones (ESB is based on WS Security, etc.)
As you may know, most of Datapower devlopement is done with tranformations. The default, established language for them is XSLT (XQuery is also and historic, less popular option).
XSLT is both one of the most powerful and most horrible language to work with. Kind of like the Perl+REGEX of the XML world...
... but there is another problem with XSLT. It is not designed to work with JSON. Making the Datapower of 10 years ago heading for a fats retirement.
At first, IBM designed pseudo-XML ways of dealing with JSON. You could convert inbound JSON to XML and work with the JSON AS XML in XSLT. The inverse operation was to use XSLT to generate JSON... it worked perfectly but kind a looked like old school HTML/PHP merging code.
So IBM came up with a good idea: GatewayScript.
(Mostly based on many other good ideas)
GatewayScript is basically ECMAScript 2015 (ES6) + CommonJS 1.0 + Many super popular JS crypto libraries.
ECMAScript is obviously more known as JavaScript.
Pertaining to your question, the main advantage of GatewayScript is to enabled easier JSON Web Services Development of all the features in the list above, for modern REST/JSON APIs, instead of older (but still good) SOAP/XML Web Services.
GatewayScript has now been present for years, no longer a "beta" option.
Here are some other neat GatewayScript features:
Access to a DOM model, representing the incoming and outgoing version of the document, in simple JS notation.
Better errors in the logs when something does not work (you get the .js line number, unlike with the XSLT errors)
Better debugging options (you can enable a line-by-line debugger)
Some examples from the web written in Node.js and other JS frameworks can work... which is amazing
A very useful IBM site (Datapower Playground) where you can learn and test GatewayScripts examples without your own Datapower, à-la-w3cschool
And more.
I hope this helps.

GhislainCote's answer is very complete but basically GatewayScript is Node.js with an added framework for handling the session object which will contain your data/payload.
There are also some special objects, e.g. service-metadata and header-metadata that will contain DataPower variables and headers.
Sample scripts are available in the store:///gatewayscript/ directory and as the store:///healthcheck.js for example.
Also review the Knowledgecenter, it contains a lot of help and information about GatewayScript:
https://www.ibm.com/support/knowledgecenter/SS9H2Y_7.7.0/com.ibm.dp.doc/gatewayscript_model.html
GatewayScript is very powerful, I've coded support for AS2 de-/en-veloping (for customers not having the B2B Module option) and RosettaNet handling in GatewayScript so there is pretty much no limit to what you can achieve!

Related

what are the technical differences between implementing SCORM vs xAPI?

I want to integrate eLearning to an existing system that I already have, I have been reading a lot about two standards SCORM and xAPI but all what I read was theoritical differences about pros and cons of each standard, anyhow I want to have a technical differences from a developper perspective about implementing those standards in the system, what are the differences by implementing those standards from a developping view?i Just want headlines of the process of developping those standards. any references or documentation about that would also be very helpful.
and would it be doable or logical to integrate one standard in the system and later on integrate the other one? for example SCORM then later if needed I integrate xAPI?
Let me start with the integration part. Yes you can do SCORM and later integrate xAPI, though that might require retooling the SCORM course, or LMS to do the xAPI part. This is done in practice. A lot of what I do is integrate existing SCORM ecosystems with xAPI and LRSs.
As for differences in SCORM and xAPI, here's some high-level info.
SCORM is a set of specifications that defines the way to package content, the way to have your content report data, and the way an LMS launches and manages SCORM content and data. xAPI is a specification that defines a REST style API and JSON data format to track interactions/activity that happened in content.
As Andrew said, SCORM content finds an embedded API object in the browser DOM and uses that to communicate very structured and specific data to an LMS. xAPI uses a REST HTTP API to communicate various data in a well defined format.
Without some creative programming, SCORM typically is content that is delivered via a browser from a Learning Management System to the client. Typically that is in the form of HTML, images, videos. xAPI can be those types of things as well but since the API is HTTP/REST-like, the support of unmanaged content - simulators, phone apps, games - is a little easier.
SCORM's data model is very clearly defined in the specification and not normally extended. xAPI's data format is defined, but the actual data is much looser and open to the needs of the developer.
SCORM has been around since about the year 2000 in various versions. It is well supported in LMSs and content development tools. And many in the eLearning space know it. xAPI is newer. Support is growing as well as the number of folks who understand it, but it is still less supported than SCORM.
One final thing of note, SCORM specs never defined a way to get data out of the LMS once the SCO attempt has ended. This made reporting and metrics difficult to do without getting the LMS vendor to build those features in. xAPI defines a GET endpoint to retrieve data (This might not be performant when you might have 100ks to millions of data points, but you can get the data back out - caveats about permissions aside) Some LRS vendors do add reporting and analytics platforms, as well as some adding ways to get your data into BI or data analysis tools.
There's more you'll find as you get into the space but that's some of the things off the top of my head.
I would recommend you read the xAPI spec first mainly because it is more easily consumed. Then look at SCORM - it has different versions (1.2, 2004 2-4th editions).
As for implementing content,
SCORM: Figure out the version to build to, create the SCOs (content that reports data to the LRS), have that find the API embedded in the HTML dom, use the defined methods (Initialize, Terminate, SetValue, GetValue) to communicate with the LMS, then package it all up in a zip with an XML manifest and support xml schema, deploy to the LMS.
xAPI: Create your content, preferably support an xAPI launch mechanism like TinCan Launch, make REST calls to the LRS's xAPI endpoint using something like Fetch or Requests, etc, host/package/deploy as you determine.
Looking at the specs is the driest but the authoritative way to learn about the different specs. There are also some very good articles and videos out there by various vendors and implementors.
The main technical difference is that SCORM uses a javascript API to communicate between a course in a window or frame wrapped by the LMS. xAPI uses a restful API to communicate with an LRS over HTTP.

Working With JAVA Callout in apigee?

can any one explain java callout a little help will do.Actually i am having several doubts regarding where to add the expressions and message flow jar and where to add my custom jar.
Can i access the resources/java folder directly and can i use it to store my data?
First, check the docs on apigee at
Customize an API using Java
http://apigee.com/docs/api-services/content/customize-api-using-java
Keep in mind Java Callouts are only supported in the paid, Apigee Edge product, not the free Developer platform.
As you decide how to use Java, you should consider this basic hierarchy of policy management:
Policy Configuration First: Apigee policy configurations are in broad use and therefore tested daily by clients and most performant.
Javascript Callout: For stuff you can't do in a standard policy there is Javascript -- keep in mind this is "Compiled Javascript" which means at the time you deploy your project the JS gets interpreted by the Java Rhino engine and then runs like native code. Very fast, very scalable, and very easy to manage as your code is all in plain text files.
Java: You have to have a pretty compelling reason to use Java. Most common cases are where you have some complex connection that needs to be negotiated with custom encryption schemas or manipulating binary content. While perfomant, it's the most difficult code to manage (you upload compiled jars, so if someone takes over your work, the source code is in a separate place than your deployment bundle), and it's the most difficult to debug in the event of a failure.
To your specific question: All Apigee variables are available in Java and Java gives you pretty much god-like powers on the local server where the code is executed. Keep in mind, Apigee's physical architecture is distributed -- your jar may run on different servers for different API calls, so any persistent data (that you might want to store locally) should really be put into Key Value Map and read as needed. Keep your API development as stateless as possible.
Hope that helps.

How popular is restlet?

I'm selecting a framework for restful service. Restlet looks promising. However, I'd like to pick something that's mainstream enough that it won't go out of support/development too soon. I know restlet has been around for quite some years. However, I'd like to know if it's popular enough. My questions are,
Any big name companies using it?
Is the default http server good enough for production?
thanks
The Restlet Framework has been available since 2005 when it was the first RESTful web framework for Java. It has support for the JAX-RS API, but its own Restlet API is both client and server-side since day one, much more comprehensive and extensible. We are free to innovate based on our community feed-back, without having to go through lengthy JCP standardization processes.
Also, we just published the 'Restlet in Action' book last September along with its version 2.1. Our internal connector is fully asynchronous and based on NIO and we are constantly stabilizing it even though it isn't ready for heavy productions yet (use the Jetty connector or a Java EE container with no change to your Restlet application).
Its consistent support for Java SE/EE, OSGi, Android, GAE and GWT with dedicated editions is unique. A port to JS (Node.js + AJAX) is also under way. We have also started work on version 2.2 with the first milestone being released (with full Java 6 support, OAuth 2.0 extension based on the final spec, etc.).
In term of references, we have many large companies using it including LinkedIn (see their GLU open source project), IBM, NVidia, ForgeRock, NASA, Sonatype, Apache Camel, Mule ESB, etc. Google has been using it internally as well. See some quotes here:
http://restlet.com/discover/quotes
In January, we'll launch a new community web site as well as APISpark, an all-in-one platform to create, host, manage and use web APIs, directly based on Restlet Framework (PaaS), so the project is active and has an exciting future!
Best regards,
Jerome Louvel
PS: I'm the Restlet Framework creator and lead developer.
The most mainstream you can get is Jersey. It is the official implementation of rest in java. Restlet came out before Jersey. But then Jersey surpassed them (in my humble opinion). I have used both Jersey and Restlet on serious projects. They are both good. However, you will find more support, more books, and more examples on Jersey.
Is this about Java? In that case, JAX-RS is the awesome new API for doing this. The best book for this is Restful Java with JAX-RS. My favorite implementation of it is Jersey, but there are others with their own unique features. All JAX-RS implementations are compatible if you don't use their distinctive features (which are minor anyway). The book explains the core API, the REST philosophy, and also some of the features unique to the different implementations. It is an excellent book. I love the introduction, where the author relates how he was used to traditional remote procedure call (like SOAP, WCF, and ordinary OO semantics) but then saw the light of the REST principles as being simpler and more elegant.
I use Tomcat as the HTTP server (servlet container). It is lightweight and is what Amazon Beanstalk uses (you can just upload your application, the WAR file, to it and it just works). You can also use GlassFish which supports many more JavaEE features, or use Apache for static pages and other things, and forward the REST requests to Tomcat/GlassFish.
The annoying thing about JAX-RS is that it's so powerful and easy that you're tempted to write ideologically-sound REST services. Unfortunately, javascript can't use many of the REST features (setting Accept header, calling anything but GET/POST, etc.) But it's not a big deal.
Jersey also has a fantastic client-side Java API that mirrors JAX-RS and reuses the same annotated classes, if your clients will be Java.
From the article
The Servlet API was released in 1998 and its core design hasn't
significantly changed since that time. It is one of the most
successful Java EE APIs, but it suffers from several design flaws and
limitations. For example, the mapping between the URI patterns and the
handlers is limited and centralized in one configuration file. Also,
it gives control of the socket streams directly to the application
developer, preventing some IO optimizations by the Servlet containers
like the full usage of NIO features. Finally it does not support HTTP
features like caching, content negotiation and content compression
very well, causing too much pain to developers and preventing them to
focus on their application specific code.
Another major concern was the lack of a modern HTTP client API in the
Java EE stack. The JDK's HttpURLConnection class is hard to use and
leaves too much HTTP features unsupported like expressing client
preferences for content negotiation.
Frequently, people were relying on third-party HTTP client APIs to
workaround those limitations. Again, NIO can't be supported with
HttpURLConnection.
In 2005, I saw an opportunity to go beyond all those limitations, and
to design a fresh API in the light of the REST principles. For the
first time, we have an API that unifies client-side and server-side
Web applications, an API that fully supports NIO and an API that lets
the developer programmatically control its container, connectors and
deployed applications without having to constantly rely on XML
descriptors.

Consuming web services in Lotus Notes 6.5

How can we consume any web services in Lotus Notes 6.5. I have seen reference to Soap Connect API. Is it the only way to do it..?
Any example will be a great help..
Thanks..
There is no out of the box solution for LotusScript and WS Consumers in R6. You would need to create your own system to shape the SOAP request, send it to the server and parse the SOAP response.
You are not going to get the benefits from using Web Services in this fashion. The whole point is that you should not have to do this.
If you use the Java route you can use Apache Axis libraries to add consuming functionality.
http://axis.apache.org/axis/
Here is a very old developerworks article on it:
http://www.ibm.com/developerworks/lotus/library/domino-webservices/
Ultimately though I'd recommend to upgrade to a later version that does support WS consumers in LotusScript. Although be aware that LS suffers in WS due to limitations of the programming language.
What I did in R6 is creating Web based agents using LotusScript which behaved like Web Services. It performed rather good for services that weren't called by too many users at the same time (as far as I remeber...)-
This presentation / sample might be helpful for you:
http://www.slideshare.net/billbuchan/jmp206-lotus-domino-web-services-jumpstart#btnNext
Full files from Bill's presentation including sample are available for download here:
http://www.hadsl.com/HADSL.nsf/Documents/Lotusphere+2008+-+JMP206+-+Web+Services+Bootcamp!OpenDocument
Another helpful link (if you want to use SOAP/Java):
http://www.ibm.com/developerworks/lotus/tutorials/lswsdom65/lswsdom65-pdf.pdf
If you are on Windows, you can use a COM object in LotusScript to call the webservice.
A good one that I used myself is PocketSOAP: http://www.pocketsoap.com/ . It has a lot of features, like support for https, using SOAP headers and sending attachments.
Many of PocketSOAPs features are unavailable or difficult to achieve even in a native R8 web service consumer, so this is an option for higher versions than Lotus Notes 6.5, too.

Best Practices Server Side Scripting or Web Services

Let me start off by stating that I am a novice developer, so please excuse the elementary nature of my question(s).
I am currently working on a Flex Application, and am getting more and more confused about when to use server side scripting, and when to develop web services. For most of the functionality I am working on, I am taking various files from the user (client), uploading to the server for processing/conversion, then sending back to client in new format.
I am accomplishing most of this using asp.net generic handlers (ashx) files, but not very confident this is best practice. But at the same time, does making web services make any more sense? What would be considered best practice for this? Any suggestions would be greatly appreciated.
The way I look at it is as follows:
Web Services mean Established Best Practice.
For most of our development, we don't need to create "Web Services", or what I'm thinking when I think REST, SOAP, and the Twitter API. You only need to start doing that once you've got something you're going to be using every day for years.
Clean and DRY code will Lead you to Creating a Web Service
If you spend the time to clearly define the parts of your upload-process-render Architecture, and you find that it can be applied to almost everything you are doing, then all you need to do to make it a Web Service is define a clear, 1-2-3 set of rules for using the system (GET/POST data, etc.). As long as you are consciously building an architecture the whole way, you'll end up creating a Web Service if it's worthy. Otherwise there's no need.
It sounds like you have a clear workflow going, I don't know anything about asp.net though.
As far as it being confusing sometimes, and best practices, I suggest the following:
Create a Flex Library Project for your "generic ashx file handling" Flex classes. Give it a cool, simple name.
Create a .NET Library Project that encapsulates all the logic for your server-side file processing. Host it online and make it open source. I recommend github. Test it as you go, and document it, its purpose and the theory behind it.
If you don't have to do anymore work at this point, and it's just plug and chug, then you've probably arrived at something that might become a Web Service, though that's probably a few years down the road.
I don't think you should try to create a Web Service right off the bat. Just make some clean and reusable code, make a few examples, get it online and open source, have others contribute and give feedback, and if it solves a specific problem, then make it a web service. You can just use REST for now probably, and build your system around that. RestfulX is a great library for that.
Best,
Lance
making web services without any sense make no sense ;)
Now in the world of FLEX as3 with flash version 10, you can easily read local files, modify them with whatever modifcation algorithm and save local files without pinging server.
You only have to use webservices if you want to get some server data or to send some data to server. that's all.
RSTanvir
Flash / Flex uses a simple HTTP POST approach for file uploads, so trying to do that using SOAP web services will be problematic. Your approach of using ASHX here sounds reasonable to me.
To send / receive data that isn't file based (e.g. a list of files the user has uploaded previously), I would recommend looking at the open source Fluorine FX library. Fluorine uses AMF which is a highly performant way of doing data transfer with Flash. It's also purely configuration-based, which means you don't need to code against any of its APIs, just configure Fluorine to expose your .NET service classes. You could easily add attributes to those same classes to expose them as SOAP web services via WCF if you need that in the future. I would not recommend using SOAP with Flex however, due to the performance losses and also because the Flex implementation of SOAP has a history of bugs and interoperability problems.

Resources