1 / 29

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

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. What is a web service?. Also known as ‘APIs’

kurt
Download Presentation

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

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. Web Services 101 James Payne Managing Director for New Media / Advancement July 30, 2013

  2. Agenda • Introductions • Web Services Overview • Definition • Examples of web services • iModules Web Services • Technologies • Using

  3. 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)

  4. What are some examples of web services? • Companies • Google • Facebook • Twitter • Yelp! • LinkedIn • Everyone

  5. 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)

  6. 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 proxy MemberMergeQuery.asmxAllows 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

  7. What technologies do I need to know? • XML • HTTP • Some Programming Language

  8. 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)

  9. HTTP (2/3) Client Request • 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. GET /index.html HTTP/1.1 Host: www.example.com Source: Wikipedia

  10. HTTP (3/3) Server Response HTTP/1.1 200 OK Date: Mon, 23 May 2005 22:38:34 GMT Server: Apache/1.3.3.7 (Unix) (Red-Hat/Linux) Content-Type: text/html; charset=UTF-8 Content-Length: 131 Connection: close <html> <head> <title>An Example Page</title> </head> <body> Hello World, this is a very simple HTML document. </body> </html> Source: Wikipedia

  11. 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

  12. 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

  13. Other Buzzwords/Acronyms You’ll Hear… JSON JavaScript Object Notation REST Representational State Transfer SOAP Simple Object Access Protocol WSDL Web Service Definition Language

  14. 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

  15. Documentation • iModules has very good web service documentation • Download it at… • https://confluence.imodules.com/display/help/iModules+Web+Services+2.1+-+Engineering+Documentation • Or just search the Internet for • imodules web service 2.1

  16. 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

  17. 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

  18. 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

  19. Using the Web Service Help Pages (/2) The Web Service Definition Language pages can be used to experiment with web service requests and responses.

  20. Using the Web Service Help Pages (2/2)

  21. 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>

  22. Creating a Request (HTTP GET) GET /ws/21/GeneralQuery.asmx/GetAllColumns?login=A309979A-AFB2-4C49-BBB7-4086B5134755&password=supersecret&controlId=896HTTP/1.1 Host: api.imodules.com You can do a GET from the browser…

  23. Creating a Request (HTTP POST) POST /ws/21/GeneralQuery.asmx/GetAllColumns HTTP/1.1 Host: api.imodules.com Content-Type: application/x-www-form-urlencoded Content-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.

  24. Placing the Request (1/2) • Create the request payload • Create an HTTP request using your language’s native functionality • - Specify URL and HTTP method (GET or POST) • 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 count • 4) Send the request • 5) Read the response • Check the status; if it’s 200, the request succeeded(*). Parse the returned XML and continue • If the status is not 200, an error has occurred. Handle the error.

  25. 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.

  26. Consuming the Response

  27. Stitch Together Calls to Get the Results You Want • For example, to get all instance and non-instance fields for gift records… • GetTransactionsAllSince • https://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 call • https://api.imodules.com/ws/21/ControlQuery.asmx • GetOneMemberByMemberIdincluding member ID, control ID, and columns • https://api.imodules.com/ws/21/ControlQuery.asmx • End loop

  28. Resources iModules Web Service v2.1 Documentation https://confluence.imodules.com/display/help/iModules+Web+Services+2.1+-+Engineering+Documentation XML http://www.w3schools.com/xml/ HTTP http://www.jmarshall.com/easy/http/ SoapUI http://sourceforge.net/projects/soapui/files/latest/download XML Pretty Print http://xmlprettyprint.com/

  29. Web Services 101 James Payne james.payne@dartmouth.edu Questions?

More Related