Accelrys Enterprise Platform 9.0 includes some significant enhancements to support the deployment of Pipeline Pilot protocols as web services.
This session will bring you up to date on the different styles of web service and options for deployment to end users and web service clients. You will also learn about techniques for publishing services using a standard REST-based model. The session will focus on practical demonstrations of taking Pipeline Pilot protocols and delivering them as REST-based web services.
(ATS6-DEV01) What’s new for Protocol and Component Developers in AEP 9.0
(ATS4-DEV04) Protocols as RESTful Services and RESTful URL Routing
1. (ATS4-DEV04) Protocols as RESTful
Services and RESTful URL Routing
Jon Hurley
Senior Manager, Platform R&D
Jon.Hurley@accelrys.com
2. The information on the roadmap and future software development efforts are
intended to outline general product direction and should not be relied on in making
a purchasing decision.
3. Summary
• Configuring Protocols as Service Endpoints
• REST
• Protocols as RESTful services
• Long Running Jobs
4. Pipeline Pilot Integration Points
Client Integration
Build clients that connect to Pipeline Pilot
and run protocol services.
Web Browser
Run Protocol .NET Client Java Client
Professional JavaScript Client
Command Line Web Port SOAP Client HTTP Client
Client
Client
.NET Client
JavaScript Client SDK Java Client SDK
SDK
Pipeline Pilot Enterprise Server
Web Apps Web Services API Admin Portal Help Portal
Protocol Runtime Environment
VB Script VB Script
Run SOAP & Telnet / ODBC /
(On (On Java Perl Python .NET SSH / SCP
Program HTTP FTP JDBC
Client) Server)
Java Perl .NET
VB Script Cmd Line
Classes Scripts Classes
Server Integration REST SOAP
Cmd Line
Extend pipelines with new Service Service DBs
components that integrate
your code, data and services.
5. Web Services API & Client SDKs
Client Server
.NET Applications .NET SDK Pipeline Pilot
Server
Java Servlets, JSP
Java Applications Java SDK
Web Applications JavaScript SDK
XML
Perl SOAP::Lite &
SOAP Protocol
APIs Database
other SOAP libs
Browsers, Http Http
Clients
Authentication
Layer
Allows cross-platform access to Pipeline Pilot services
6. Protocols as Web Services
• Mapping protocols to Web Services
– “Visual” Services
– Parameter Style
– Document Style
7. RESTful Services
• Representational State Transfer
• Typically pass documents (eg XML, JSON) between client
& server that represent state of a resource
• Uses existing verbs rather than creating arbitrary function
names – GET, PUT, POST, DELETE
• Resources identified by URI, so URI mapping required to
underlying functions
8. RESTful URIs
RESTful URIS refer to resources
Two types of URIs
Collection - http://example.com/compounds/
Element - http://example.com/compounds/acc123456
5 Common Methods
Method Purpose
GET For retrieving a data resource or a resource collection
POST For creating a new resource
PUT For replacing a resource
PATCH For updating resource content
DELETE For removing a resource
9. Zoo Examples
• Collection of animals
• Stored in a cache loaded from ‘data/Tables/zoo.txt’
• List, edit, delete animal records
• Set of protocols that are exposed as RESTful services
• Demonstrated using the Chrome Browser ‘Advanced Rest
Client’
11. List Service
http://{server}/zoology/animals/
[
{"id":1,"animalname":"aardvark"},
{"id":2,"animalname":"antelope"},
{"id":3,"animalname":"bass"},
{"id":4,"animalname":"bear"},
…
12. Individual Animal Service
http://{server}/zoology/animals/1
[
{"id":"1","animalname":"aardvark","type
":"mammal","milk":"1","legs":"4","tail"
:"0","eggs":"0","feathers":"0"}
]
13. List the ‘B’ Animals
http://{server}/zoology/banimals/
[
{"id":3,"animalname":"bass"},
{"id":4,"animalname":"bear"},
{"id":5,"animalname":"boar"},
{"id":6,"animalname":"buffalo"}
]
14. List the Animals with an XML format
http://{server}/zoology/canimals/xml
<?xml version="1.0" encoding="UTF-8"?>
<animals>
<animal id="7" animalname="calf" />
<animal id="8" animalname="carp" />
<animal id="9" animalname="catfish" />
<animal id="10" animalname="cavy" />
</animals>
15. Defining URL Routes
• URL Route definitions are provided in package files
• In your package define the routes in a urls.conf file
• Include a reference to this file in package.conf:
…
# URL routing configuration
Include $(package)/urls.conf
16. Defining URL Routes
<url REST AUTH>
method GET
request /zoology/animals/
protocol Protocols/Web Services/AcclDev/zoo/Actions/animal/List
summary List all animals in the zoo.
<url>
request /zoology/banimals/
param NameFilter B
querystring Off
summary List all animals whose name starts with the letter B.
</url>
</url>
18. Some Edit URLs
• Add new animals
• POST: {root}/zoology/animals/
• Header: Content-type: application/json
• By default the body is stored in the first parameter on the
protocol (override with _bodyParam in URL route)
• Edit an existing animal
• PUT: http://meteorbs:9944/zoology/animals/
• With full data record
• PATCH: http://meteorbs:9944/zoology/animals/
• With partial data record
19. Specifying the return format
• Services can use these methods to control the return
format
• Accept Header
• Accept: application/json
• Format Query String argument
• http://{server}/zoology/formanimals/1
• OR
• http://{server}/zoology/formanimals/1?format=xml
• Overrides the format from the Accept header
20. A Long Running Job
If the action may take more than a few seconds to run then make it a long running
job so it can be polled from the client.
In package.conf
…
<url>
method GET
request /myapp/slowjob
protocol Protocols/Examples/My Protocol
param _blocking 0
</url>
…
21. Running Job RESTful URLs
Method URL path Description
GET /jobs/ List of the current user’s jobs
GET /jobs/job-id Details for the specified job
GET /jobs/job-id/status Status code for the job (e.g. running)
GET /jobs/job-id/files List of links to job directory files
GET /jobs/job-id/results Results of the job
DELETE /jobs/job-id Release the job (terminate if still running)
DELETE /jobs/job-id/stop Stop the current job
22. Accessing RESTful services from Protocols
• Use JSON Reader (or XML Reader) or HTTP Connector
• E.g. $(ServerRoot)/zoology/animals/
23. Summary
• Package developers can configure RESTful endpoints for
protocols
• Next Steps
– Get the demo package with which to experiment
• testpkg-svc1
– aep_restful_web_services.pdf