Web Service

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Which markup language can be used in RESTful web services?

JSON and XML.

What is JSON

JSON(JavaScript Object Notation) is simple data exchange format. It is language and platform independent.

Can you use GET request instead of PUT to create a resource?

No, you are not supposed to use POST or GET. GET operations should only have view rights.

What are the data types supported by JSON?

- Number - String - Boolean - Array - Object - Null

What is the difference between PUT and POST?

- PUT puts a file or resource at a particular URI and exactly at that URI. If there is a file or resource at that URI, PUT changes that file or resource. If there is no resource or file, PUT makes one. - POST sends data to a particular URI and expects the resource at that URI to deal with the request. The web server at this point can decide what to do with the data in the context of specified resource.

What are some important things to consider when designing a RESTful web service?

- REST API should adhere to some standards. For example, OAuth for authentication, JSON and XML for data, HTTP for transport, and URI standard. - use JSON as output. It's convenient for JavaScript to consume web service; but you should also support XML, because not every system consume JSON. - Don't make change w/o versioning the service.

Some key characteristics of REST?

- REST is stateless, so there is no storage of session data on the client. - With a well applied REST API, the server could be restarted between two calls as every data is passed to the server - Web service mostly uses POST method to make operations, whereas REST uses GET to access resources.

What tools are required to test your web services?

- SOAPUI tool for SOAP - Firefox "poster" plugin for RESFful services.

Primary goal of REST

- Scalability: REST based system should work well with many clients and many transactions. - Generality of interfaces: should adaptable to any business process. - Independent deployment of components: means host and clients don't need to be using the same operating system.

Name three method of NSXML parser.

- did start element - did end element - found character

Which xml parser we use on iphone?

"NSXML" parser.

Which type of parse does iphone support?

"SAX" parser.

Tell methods used in NSURLConnection

- Connection did receive response - Connection did receive data - connection fail with error - connection did finish loading

Tell the difference between DOM and SAX parser?

- DOM is documents based parser. - SAX is an event driven parser.

Describe REST?

REST = Representational State Transfer. REST is a way of building web services by following a set of specific constraints between consumers and providers: - Separation of concerns

Explain what is REST and RESTful?

REST represents Representational State Transfer; it it relatively new aspect of writing web services. RESTful is referred for web services written by applying REST architectural concept are call RESTful services, it focuses on system resources and how state of resource should be transported over HTTP protocol to a different clients written in different language. In RESTful web service http methods like GET, POST, PUT and DELETE can be used to perform CRUD operations.

What are resources in a REST architecture?

Resources are identified by logical URLs; it is the key element of a RESTful design. Unlike SOAP web services, you view the product data as a resource and this resource should contain all the required information.

Which JSON framework is supported by iOS?

SBJson framework. It is a JSON parser and generator for Objective-C. SBJson provides flexible APIs and additional control that makes JSON handling easier.

Explain the architetural style for creating web services?

The architectural style for creating web services are - HTTP for client server communication - XML/JSON as formatting language - Simple URI as the address for services - Stateless communication

What is parsing?

To get data from web service we use parsing.

URI vs URL

URI - Uniform Resource Identifiers.

What is recommended way to do deletion for restful web service?

By doing delete HTTP method?

What are the HTTP methods supported by REST?

HTTP methods supported by REST are: - GET: It requires a resource at the request URL. It should not contain a request body as it will be discarded. Maybe it can be cached locally or on the server. - POST: It submits information to the service for processing; it should typically return the modified or new resource. - PUT: At the request URL it updates the resource - DELETE: At the request URL it removes the resource. - OPTIONS: It indicates which techniques are supported - HEAD: About the request URL it returns meta information.

What is json-parser

JSON(Java script object notations) is a parser used to get data from web server.

What is webservice?

To get data in form of xml, by using this we can get data from a server.

Why use JSON over XML?

- It is faster and lighter than XML as on the wire data format. - XML daa is typeless while JSON objects are typed - JSON types: Number, Array, Boolean, String - XML data are all string. - Data is readily available as JSON object in JavaScript - Fetching values is as reading from an object property in your JavaScript code.

How do you handle asynchronous networking?

- The modern approaches would be to use sendAsynchronousRequest:queue:completionHandler: - Traditional approach where we implement the NSURLConnectionDelegate methods and initiate the request with NSURLRequest. - Better Approach: NSURLSession. It comes with block based approach and delegate based approach. - Best Approach: AFNetworking.

How do you usually do networking?

..

What's the difference between SOAP and REST?

1. SOAP is a protocol through which two computer communicates by sharing XML document, while REST is a service architecture and design for network-based software architecture. 2. SOAP supports only XML, and REST supports many different data formats, such as JSON,XML. 3. SOAP based read cannot be cached, but REST can. 4. SOAP is like a custom desktop application, closely connected to the server. A REST client is more like a browser; it knows how to standardized methods and an application has to fit inside it. 5. REST is faster than SOAP because of it's light-weighted feature. 6. SOAP runs on HTTP but envelopes the messages. REST uses the HTTP headers to hold meta information.

What's the form of RESTful request?

A RESTful request is typically in form of URI. Structure of URI depends on specific service. Requests can also include parameters in body of request as JSON, XML or other format.

Benefit and disadvantages of using sendAsynchronousRequest:queue:completionHandler:

Benefits: - This does away with the repetive code that handles intermediate results - Race conditions are avoided which sometimes occur if using NSURLConnection delegates, as some of the part of the delegate gets prematurely released. The block here is retained. - In case of multiple asynchronous request, the code for handling each of the response is cleanly separated and thus less change of mixup. Disadvantages: - You lose some control over the operations. Image the scenario when you will need to cancel the download of a large chunk of data. In the above implementation, there is no way you can actually cancel the request without leaking memory. ( you could do it by cancelling NSOpertion within the queue, but doing this will have to cancel all your activities yourself) - As stated in the first beneficial point, you can not handle intermediate results. - With this approach when a request is made, it either fails or succeeds, and it fails even for authentication challenges.

Benefits and disadvantages of using traditional approach

Benefits: - you get to handle authentication challenges through delegates. - Parsing data on the fly is easy - can easily cancel the connection by just calling the cancel method disadvantages: - if there are multiple request, then in the authentication challenge handler it becomes difficult to understand for which request the authentication challenge is thrown.

What is CRUD?

CRUD stands for create, read, update, and delete. These are the four basic functions of persisent storage. In HTTP: C - PUT/POST R - GET U - PUT/PATCH D - DELETE

How would you use NSURLConnection on a background thread?

You can do this by using sendAsynchronousRequest

Which class and method is used to parse JSON data in iOS?

[NSJSONSeriralization JSONObjectWithData: data options: opt error:err];

the advantages and disadvantages about synchronous vs asynchronous connections.

Synchronous Advantage: - easy to implement Synchronous disadvantage: - the thread which called the connection method will be blocked until the connection finish or timeout. That means we need to create a new thread to handle the connection - it's not possible to cancel a synchronous connection. - there is no way to deal with authentication challenges. - impossible to parse data on the fly. Asynchronous advantage: - you don't have to create a new thread for the connection - you can easily cancel the connection just by calling the cancel method. - if you need authentication just implement the required delegate methods - parsing data on the fly is easy disadvantage: - require a bit more of code

Name those classes used to establish connection b/w application to webserver?

a. NSURL b. NSURL REQUEST c. NSURL CONNECTION

Difference between HTTP and HTTPS.

· HTTP stands for HyperText Transfer Protocol, whereas, HTTPS is HyperText Transfer Protocol Secure. · HTTP transmits everything as plan text, while HTTPS provides encrypted communication, so that only the recipient can decrypt and read the information. Basically, HTTPS is a combination of HTTP and SSL (Secure Sockets Layer). This SSL is that protocol which encrypts the data. · HTTP is fast and cheap, where HTTPS is slow and expensive. As, HTTPS is safe it's widely used during payment transactions or any sensitive transactions over the internet. On the other hand, HTTP is used most of the sites over the net, even this blogspot sites also use HTTP. · HTTP URLs starts with "http:// " and use port 80 by default, while HTTPS URLs stars with "https:// " and use port 443. · HTTP is unsafe from attacks like man-in-the-middle and eavesdropping, but HTTPS is secure from these sorts of attacks.


Set pelajaran terkait

svarbiausi XVIII a. - XIX a. kuriniai

View Set

Psychology chapter 15 Psychological Disorders

View Set

Alexander the Great Ancient Greece Assessment #2

View Set

chapter 6 Internal control, cash and merchandise

View Set

Perfect Competition, imperfectly competitive markets and monoploy

View Set