Presentation on theme: "Practical Uses for Web Services in Application Express"— Presentation transcript:
1 Practical Uses for Web Services in Application Express Web services have been around since the last millennium, but what can you actually do with them? Is there any practical reason to consume web services in an Application Express application?In the past, the predominant Web service standard was SOAP. While it is still widely used, it is not simple. Requests and response are XML wrapped in SOAP Envelopes, whose structure is defined by one of the very large specifications either 1.1 or 1.2.Nowadays, RESTful Web services are all the rage. All the major players on the Web, Google, Amazon, Yahoo, Netflix, etc. have RESTful API’s. RESTful Web services are much simpler, and hopefully through the course of this presentation, you will see why. Also, hopefully you will see why Application Express has many cool features that allow it to be great platform for RESTful Web service clients.
2 The following is intended to outline our general product direction The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remain at the sole discretion of Oracle.
3 <Insert Picture Here> Agenda<Insert Picture Here>Web services introductionWeb service support in Application ExpressAmazon S3APEX_WEB_SERVICE APIWeb Service Tools and DebuggingAdditional resourcesQ & A
4 <Insert Picture Here> Web Services Definition“Web services are typically application programming interfaces (API) or web APIs that are accessed via Hypertext Transfer Protocol and executed on a remote system hosting the requested services. Web services tend to fall into one of two camps: Big Web Services and RESTful Web Services.”
7 RESTful Style Web Services REpresentational State TransferRESTful Web service requestHTTP Method (GET, PUT, POST, DELETE, HEAD) indicates method of the serviceHTTP URI (path) indicates the resourceHTTP headersHTTP entity-body (parameter name/value pairs)RESTful Web service responseXMLTextJSONA RESTful Web service request defines the method it is invoking by the HTTP Method (sometimes called HTTP Verb). If you do a GET, it means you are requesting something from the service. If you do a PUT, or POST, you are creating or modifying something on the service. I am sure you can guess what DELETE does. HEAD just means give me the meta data of the particular resource. The request is also composed of a URI, optionally HTTP Headers, and a body, which could simply be a binary payload, base64 encoded payload (common in content Web services), or could be a list of parameter name and value pairs.The response from a RESTful service is Text (sometimes comma separated), XML, or JSON. Many services allow the requester to specify how they want the response.-Came from Roy Fieldings 2000 Ph.D. dissertation-REST is resource oriented, as opposed to object, or RPC
8 RESTful Support Application Express 4.x Expose report regions as RESTful Web serviceWizard to create RESTful Web referenceNEW in 4.1: Testing interface while creating the referenceTest/Edit RESTful Web referenceWizard to create form on RESTful Web referenceWizard to create form and report on RESTful Web referenceNEW in 4.2: Support for JSON responsesSince 4.0, you have been able to interact with RESTful style web services. Once you define a reference to the service, you can create a form on the request and response, or a form and a report on the response. In 4.2, there is some type of support for JSON feeds that are returned from some services.
9 Amazon Simple Storage Service (S3) Storage for the InternetDesigned to provide % durability and 99.99% availabilityDesigned to sustain the concurrent loss of data in two facilitesWrite, read, delete objects from 1 byte to 5 terabytesObjects are stored in “buckets” – a container for objectsCommon use cases:Content storage and distributionBackup or disaster recovery
10 Amazon S3 – Technical Details Create an AWS account,Sign up for an S3 account,AuthenticationAuthorization HTTP headerAWS AWSAccessKeyId:SignatureSignature is HMAC-SHA1 of selected elements from the request, AWS Secret Key is used for the keyUses REST or SOAP interfaces
11 Amazon S3 – Technical Details Endpoint: http(s)://s3.amazonaws.comCommon HTTP Headers for all interactionsHost: <bucket_name>.s3.amazonaws.comDate: Convert to GMT, and then use format Dy, DD Mon YYYY HH24:MI:SS GMTAuthorization: AWS <AWSAccessKeyId>:<Signature>
12 Amazon S3 – Technical Details – Common Operations List All BucketsCreate BucketDelete BucketList Bucket ContentsGet ObjectAdd ObjectDelete Object
13 Contains function to parse response based on an XPath expression apex_web_service APIAllows you to interact with Web services (SOAP, REST, RPC) in Application Express anywhere you can write PL/SQLIncludes functions to encode/decode binary data to/from base64 encodingContains function to parse response based on an XPath expressionGlobals to retrieve/set HTTP Headers and cookiesUse the APEX_WEB_SERVICE API to invoke a Web service and examine the response anywhere you can utilize PL/SQL in Application Express.The following are examples of when you might use the APEX_WEB_SERVICE API:When you want to invoke a Web service via an On Demand Process using AJAX.When you want to invoke a Web service as part of an Authentication Scheme.When you need to pass a large binary parameter to a Web service that is base64 encoded.When you want to invoke a Web service as part of a validation.
14 APEX_WEB_SERVICE MAKE_REST_REQUEST Function - Syntax APEX_WEB_SERVICE.MAKE_REST_REQUEST( p_url IN VARCHAR2, p_http_method IN VARCHAR2, p_username IN VARCHAR2 default null, p_password IN VARCHAR2 default null, p_proxy_override IN VARCHAR2 default null, p_body IN CLOB default empty_clob(), p_body_blob IN BLOB default empty_blob(), p_parm_name IN WWV_FLOW_GLOBAL.VC_ARR2 default empty_vc_arr, p_parm_value IN WWV_FLOW_GLOBAL.VC_ARR2 default empty_vc_arr, p_wallet_path IN VARCHAR2 default null, p_wallet_pwd IN VARCHAR2 default null ) RETURN CLOB;Although this slide is ugly, it does present some useful information, and is especially relevant to our next demo. It shows the make_rest_request function of the apex_web_service API. Only the URL, HTTP Method is required. The inputs to the Web service you invoke could be a CLOB or BLOB payload (again, useful for content API’s, like Amazon’s S3) or a table of parameter names and parameter values.
16 Web Service Tools and Debugging Web Service Reference testing interfaceAltova XMLSpyGood for inspecting responseHas utility to give you XPath to response nodesProxyTrace,Allows you to inspect the exact HTTP traffic (including headers) for a web service request/responseSet proxy of your client to go through ProxyTrace to inspect the traffic
17 Application Express on OTN: http://otn.oracle.com/apex Additional ResourcesApplication Express on OTN:Application Express Web Service Integration Page:Application Express 4.0 Web Services Evaluation GuideWeb Service Integration Sample ApplicationsWeb Service Integration WhitepapersBlog: