Web Services 101 James Payne Managing Director for New Media / Advancement July 30, 2013.

29
Web Services 101 James Payne Managing Director for New Media / Advancement July 30, 2013

Transcript of Web Services 101 James Payne Managing Director for New Media / Advancement July 30, 2013.

Page 1: Web Services 101 James Payne Managing Director for New Media / Advancement July 30, 2013.

Web Services 101

James PayneManaging Director for New Media / Advancement

July 30, 2013

Page 2: Web Services 101 James Payne Managing Director for New Media / Advancement July 30, 2013.

Agenda

Introductions Web Services Overview

Definition Examples of web services

iModules Web Services Technologies Using

Page 3: Web Services 101 James Payne Managing Director for New Media / Advancement July 30, 2013.

What is a web service?

- Also known as ‘APIs’- A building block for ‘Service-Oriented

Architecture’ (SOA)- Used to tie systems together- Used to provide access by a provider to

services or data to a consumer other than a browser… But sometimes to a browser (AJAX)

Page 4: Web Services 101 James Payne Managing Director for New Media / Advancement July 30, 2013.

What are some examples of web services?

Companies- Google- Facebook- Twitter- Yelp!- LinkedIn- Everyone

Page 5: Web Services 101 James Payne Managing Director for New Media / Advancement July 30, 2013.

What are they used for?

Example: Real Estate Web Site- IP location lookups (Various)- Real estate listings (MLS)- Secondary School Details (education.com)- Business Reviews (Yelp!)- Job Listings (simplyhired.com)- Census Data (www.census.gov)- Custom Mapping (Google)- Advertising details for integrated

marketing (Various)

Page 6: Web Services 101 James Payne Managing Director for New Media / Advancement July 30, 2013.

What can I do with iModules web services?

There are actually seven web services…

GeneralQuery.asmx Provides access to non-instance fields that are not specific to any Form

ControlQuery.asmx Provides access to fields that are specific to a form

TransactionsQuery.asmx Instance fields that are specific to a commerce transaction

EmailCategoryQuery.asmx Allows the import and export of Email Category opt-out information

LoginQuery.asmx Allows logging a constituent in by proxyMemberMergeQuery.asmx Allows queuing a non-member record and an

associated constituent record for the nightly Member Merge process

ContentQuery.asmx Allows pulling event listing / calendars, and event content information

Page 7: Web Services 101 James Payne Managing Director for New Media / Advancement July 30, 2013.

What technologies do I need to know?

- XML- HTTP- Some Programming Language

Page 8: Web Services 101 James Payne Managing Director for New Media / Advancement July 30, 2013.

HTTP (1/3)

- A request/response protocol for data communications between computers

- Resources are specified with a URL – Uniform Resource Locator- A number of request types (or methods) are supported; GET,

POST, PUT, DELETE, others- A request returns a status and possibly some additional

diagnostic or application data- 200 – Success- 401 – Unauthorized (*)- 404 – Not Found- 400 – Bad Request- 418 – I’m a teapot (IETF RFC 2324)

Page 9: Web Services 101 James Payne Managing Director for New Media / Advancement July 30, 2013.

HTTP (2/3) Client Request

GET /index.html HTTP/1.1Host: www.example.comSource: Wikipedia

- The first line of an HTTP request consists of a method, a resource specification, and an optional version number.

- A number of header lines (key/value pairs) may follow.- Depending on the method, a content body may be attached.

Page 10: Web Services 101 James Payne Managing Director for New Media / Advancement July 30, 2013.

HTTP (3/3) Server Response

HTTP/1.1 200 OKDate: Mon, 23 May 2005 22:38:34 GMTServer: Apache/1.3.3.7 (Unix) (Red-Hat/Linux)Content-Type: text/html; charset=UTF-8Content-Length: 131Connection: close

<html> <head> <title>An Example Page</title> </head> <body> Hello World, this is a very simple HTML document. </body></html>

Source: Wikipedia

Page 11: Web Services 101 James Payne Managing Director for New Media / Advancement July 30, 2013.

XML

- XML is a markup language designed to facilitate transportation and storage of data in a human readable format.

- XML has similarities to HTML but is different; HTML is designed to display data

Simple Example:

<note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body>

</note>

Source: http://www.w3schools.com/xml/note.xml

Page 12: Web Services 101 James Payne Managing Director for New Media / Advancement July 30, 2013.

Some Programming Language

The language used must…- Support string handling and concatenation- Support HTTP network interaction- Support some sort of data input and output

That’s just about every language…

- Perl, Java, VB, VBScript, C#, Python

Page 13: Web Services 101 James Payne Managing Director for New Media / Advancement July 30, 2013.

Other Buzzwords/Acronyms You’ll Hear…

JSON JavaScript Object Notation

REST Representational State Transfer

SOAP Simple Object Access Protocol

WSDL Web Service Definition Language

Page 14: Web Services 101 James Payne Managing Director for New Media / Advancement July 30, 2013.

How do I use them?

- Documentation- Access- Options for Calling Web Services- Crafting the URL- Using the Web Service Help Pages - Creating the request - Placing the request- Consuming the response

Page 16: Web Services 101 James Payne Managing Director for New Media / Advancement July 30, 2013.

Access

- You will need a username and password to access web services

- Tell your account manager that you would like to use web services

- Your account manager will arrange access for you

Page 17: Web Services 101 James Payne Managing Director for New Media / Advancement July 30, 2013.

Options for Calling the Web Services

There are several ways of calling the web services from your program…

- SOAP 1.1 or 1.2- HTTP GET- HTTP POST

Page 18: Web Services 101 James Payne Managing Director for New Media / Advancement July 30, 2013.

Crafting the URL

Base URL (USA)…https://api.imodules.com/ws/21/

Web Service…GeneralQuery.asmx

Operation…GetAllColumns

For SOAP or WSDL…https://api.imodules.com/ws/21/GeneralQuery.asmx

For HTTP get…https://api.imodules.com/ws/21/GeneralQuery.asmx/GetAllColumns? login=string&password=string

For HTTP post…https://api.imodules.com/ws/21/GeneralQuery.asmx/GetAllColumns

Page 19: Web Services 101 James Payne Managing Director for New Media / Advancement July 30, 2013.

Using the Web Service Help Pages (/2)

The Web Service Definition Language pages can be used to experiment with web service requests and responses.

Page 20: Web Services 101 James Payne Managing Director for New Media / Advancement July 30, 2013.

Using the Web Service Help Pages (2/2)

Page 21: Web Services 101 James Payne Managing Director for New Media / Advancement July 30, 2013.

Creating a Request (SOAP)

Example Request…

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:con="http://imodules.com/WebServices/ControlQuery/"> <soapenv:Header/> <soapenv:Body> <con:GetAllColumns> <con:login>A309979A-AFB2-4C49-BBB7-4086B5134755 </con:login> <con:password>supersecret</con:password> <con:controlId>896</con:controlId> </con:GetAllColumns> </soapenv:Body> </soapenv:Envelope>

Page 22: Web Services 101 James Payne Managing Director for New Media / Advancement July 30, 2013.

Creating a Request (HTTP GET)

GET /ws/21/GeneralQuery.asmx/GetAllColumns?login=A309979A-AFB2-4C49-BBB7-4086B5134755&password=supersecret&controlId=896 HTTP/1.1Host: api.imodules.com

You can do a GET from the browser…

Page 23: Web Services 101 James Payne Managing Director for New Media / Advancement July 30, 2013.

Creating a Request (HTTP POST)

POST /ws/21/GeneralQuery.asmx/GetAllColumns HTTP/1.1Host: api.imodules.comContent-Type: application/x-www-form-urlencodedContent-Length: 64

login=A309979A-AFB2-4C49-BBB7-4086B5134755 &password=supersecret&controlId=896

Note: The SOAP method on a previous slide also utilizes a POST operation.

Page 24: Web Services 101 James Payne Managing Director for New Media / Advancement July 30, 2013.

Placing the Request (1/2)

1) Create the request payload2) Create an HTTP request using your language’s native

functionality- Specify URL and HTTP method (GET or POST)

3) Set content_type and content_length for POST and SOAP- Content type is application/x-www-form-urlencoded or

text/xml- Content length is based on the request body size character

count4) Send the request5) Read the response6) Check the status; if it’s 200, the request succeeded(*). Parse the

returned XML and continue7) If the status is not 200, an error has occurred. Handle the error.

Page 25: Web Services 101 James Payne Managing Director for New Media / Advancement July 30, 2013.

Placing the Request (2/2)

Note: If the username or password is wrong, the iModules web service call will return 200/OK instead of 401/Unauthorized. The return content body will indicate that the credentials are wrong.

Page 26: Web Services 101 James Payne Managing Director for New Media / Advancement July 30, 2013.

Consuming the Response

Page 27: Web Services 101 James Payne Managing Director for New Media / Advancement July 30, 2013.

Stitch Together Calls to Get the Results You Want

For example, to get all instance and non-instance fields for gift records…

GetTransactionsAllSincehttps://api.imodules.com/ws/21/TransactionsQuery.asmx

Loop…

Filter based on control IDs for gift forms

GetAllColumns for a control to use to pass to the next control-oriented service callhttps://api.imodules.com/ws/21/ControlQuery.asmx

GetOneMemberByMemberId including member ID, control ID, and columns https://api.imodules.com/ws/21/ControlQuery.asmx

End loop

Page 29: Web Services 101 James Payne Managing Director for New Media / Advancement July 30, 2013.

Web Services 101

James [email protected]

Questions?