1 / 16

Advantage webapi

Advantage webapi. Peter funk Software engineer, advantage r&d. MAY 20, 2011. agenda. Introduction REST Framework Security Authentication Database specific Client development pattern. Introduction. ADS WebAPI implements a RESTful web service

wyome
Download Presentation

Advantage webapi

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Advantage webapi Peter funk Software engineer, advantage r&d MAY 20, 2011

  2. agenda • Introduction • REST • Framework • Security • Authentication • Database specific • Client development pattern

  3. Introduction • ADS WebAPI implements a RESTful web service • Accessible from any client that can implement HTTP web requests • Requirements of a client’s library (PUT, GET, POST, DELETE), SSL, basic authentication • Data dictionary • ADS 10.10 (latest EBF, work in progress)

  4. REST • Representational State Transfer (ReST) • Client and server architecture, stateless • Client transitions from states or at “rest” when idle • Transitions during requests • Interacts with user while at rest • Uses links (URIs) to initiate a new state transition • Each request contains all information to service the request • Methods GET (SELECT), PUT (UPDATE), POST (INSERT), DELETE (DELETE) • Recommended reading: RESTful Web Services by Leonard Richardson and Sam Ruby

  5. framework • oData – Open Data Protocol (odata.org) • Web protocol for querying and updating data • Built on top of HTTP, AtomPub, and JSON • AtomPub (Atom Publishing Protocol) • XML • JSON – JavaScript Object Notation (json.org) • Lightweight data-interchange format • Easy to read, parse, and generate

  6. Example XML http://server/adsweb/exampledb/v1/tables/demo10(5) <?xml version="1.0" encoding="iso-8859-1" standalone="yes"?> <feed xml:base="http://server/adsweb" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" mlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom"> <title type="text">demo10</title> <id>http://server/adsweb/exampledb/v1/tables/demo10</id> <updated></updated> <link rel="self" title="demo10" href="demo10" /> <entry> <id>http://server/adsweb/exampledb/v1/tables/demo10(5)</id> <title type="text"></title> <updated></updated> <author> <name /> </author> <link rel="edit" title="demo10" href="http://server/adsweb/exampledb/v1/tables/demo10(5)" /> <category term="Model.demo10" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /> <content type="application/xml"> <m:properties> <d:DEPTNUM m:type="Edm.Int16">18</d:DEPTNUM> <d:LASTNAME m:type="Edm.String">Costello</d:LASTNAME> <d:FIRSTNAME m:type="Edm.String">Angie</d:FIRSTNAME> <d:DOH m:type="Edm.DateTime">1989-07-16T00:00:00</d:DOH> <d:SALARIED m:type="Edm.Boolean">true</d:SALARIED> <d:EMPID m:type="Edm.Int32">5</d:EMPID> <d:PHONE m:type="Edm.String">381-8410</d:PHONE> <d:DOB m:type="Edm.DateTime">1948-04-19T00:00:00</d:DOB> <d:EXTENSION m:type="Edm.Int16">7066</d:EXTENSION> <d:SOC_SEC_NU m:type="Edm.String">538-62-6755</d:SOC_SEC_NU> <d:MARRIED m:type="Edm.Boolean">true</d:MARRIED> <d:DIVISION m:type="Edm.String">Production</d:DIVISION> <d:BRANCH m:type="Edm.String">Los Angeles</d:BRANCH> </m:properties> </content> </entry> </feed>

  7. Example JSON http://server/adsweb/exampledb/v1/tables/demo10(5)?$format=json { "d": { "results": [ { "__metadata": { "uri": "http://server/adsweb/exampledb/v1/tables/demo10(5)", "key_fields": "EMPID", "rows_affected": 0, "last_autoinc": 0 }, "DEPTNUM": 18, "LASTNAME": "Costello", "FIRSTNAME": "Angie", "DOH": "1989-07-16T00:00:00", "SALARIED": true, "EMPID": 5, "PHONE": "381-8410", "DOB": "1948-04-19T00:00:00", "EXTENSION": 7066, "SOC_SEC_NU": "538-62-6755", "MARRIED": true, "DIVISION": "Production", "BRANCH": "Los Angeles" } ] } }

  8. Apache module • WebAPI is an Apache module that communicates with ADS • Security updates to Apache, not ADS • Configurable with ads.conf • Authentication • SSL • Expose your database • Connection strings

  9. security • Outward security handled by Apache • Keep Apache up to date • Web server & database server on separate machines • Require SSL (Secure Sockets Layer) • Encryption • Certificate • Self signed for testing • Official for production

  10. authentication • DbAuthentication • “None”: No authentication required. Note if Apache is not prompting for authentication, you will very likely want to only expose this data as a read-only feed. To accomplish this, set up a database user with read-only privileges, and specify that username and password in your DbConnection string. It would be a great idea to test this setup by trying to perform an update as well. • “Database” (default): User credentials will be prompted for, and routed to Advantage for verification via existing user accounts in the database. • “Apache”: Used if you would rather use an Apache module for authentication. If specified, you must then provide Apache directives for your specific module. For example, you could use the AuthBasicProvider and AuthUserFile directives to implement authentication via an Apache passwd file. Note if you use “Apache” authentication you must then provide a database username and password in your DbConnection string.

  11. Database specific • Conflicts • Rowversion, modtime • Stored procedures and triggers • Transactions on server-side only or with batch updates • Primary keys • Non-nullable fields • Data Dictionary • Binary data is base64 encoded/decoded • QURTIFJ1bGVzIEJhYnkh

  12. Development pattern • HTTP request • XML or JSON deserialization • Proxy classes • Look for client libraries that can make these easy for you • Utilities • LINQPad • Fiddler • Chrome Browser • Curl

  13. futures • oData specification evolving • Delta links provide updates to data stored locally on the client • Apache packaged with ADS install • Apache updates with ADS updates (EBFs)

  14. Getting started • Advantage Web API blog post • http://jdmullin.blogspot.com/2010/09/advantage-web-api.html • Web API Quick Start Guide • https://docs.google.com/document/d/1dQsxVf8K0t4HmHvNoaAgx2c_UTDnoo1cTVNHvAjtD78/edit?hl=en&authkey=CNCJj44B • Beta user signup • http://www.surveymonkey.com/s/D3R6NGS • User group forums • news://DevZone.AdvantageDatabase.com/advantage.webapi • All things oData • http://www.odata.org • http://www.odata.org/developers/odata-sdk • Client libraries • .NET JSON.NET http://james.newtonking.com/pages/json-net.aspx • Java Restlethttp://www.restlet.org/ • Ruby ruby_odatahttps://github.com/visoft/ruby_odata • iOS Objective-C http://odataobjc.codeplex.com/

  15. videos • Consuming oData from .NET (and other MS environments) • http://msdn.microsoft.com/en-us/data/video/gg591296

More Related