SlideShare ist ein Scribd-Unternehmen logo
1 von 46
Downloaden Sie, um offline zu lesen
WEB SERVICES BOOTCAMP
       Bill Buchan - HADSL
AGENDA

•   Introduction

•   Web Services Overview

•   Using Domino to provide Web Services

•   Using Notes to consume Web Services

•   Summary, Q+A
INTRODUCTION

•   I am Bill Buchan. I am:

    •   A blogger - http://www.billbuchan.com

        •   I was blogging when it was called ‘Talking rubbish on the
            internet’.

        •   Some things never change.

    •   A principal of HADSL - http://www.hadsl.com
WE DO COMPLICATED STUFF

•   Our product deals with enterprise user and resource/service
    management

•   Continually pushing the Notes platform

•   Currently coding around the OOO and ID Vault API’s

•   All my presentations are based on the work we do in FirM
LOTS OF CONTENT HERE
•   This takes you from a low level in a subject to a good level of
    expertise

•   Little existing knowledge is assumed

    •   But we assume your are developers, and are familiar with
        LotusScript

•   No xPages, Java

•   This is a 2 hour presentation, squeezed into 45 minutes

    •   This will be fast

                                      6
I HAD THE PLEASURE


•   Of working in Holland for many
    years

•   Be gentle!

•   Questions at the end...
A QUICK OVERVIEW
•   Web services are:

    •   A standard application to application protocol for exchanging structured data

        •   Usually (but not always) using the http protocol

        •   Usually (but not always) using XML

        •   Usually we provide meta-information on what our service will do, using a
            language called WSDL (Web Service Description Language) – formatted in
            XML.

•   Web services are Language independent, Platform independent, Data format
    representation independent

•   But hopefully you all knew this already...
WEB SERVICES ARCHITECTURE

•   The players:

    •   The Web Service server

        •   Can answer questions on what it can do

        •   Can accept requests from Web Service clients

        •   Can respond to requests from Web service clients
WEB SERVICES PROTOCOL
 A typical web service session looks like:

  Client to Web Service Server

       “Tell me the answer to this question”

  Web Service Server

       “Here it is”

 Conclusion:

  The clients drive the conversation

  The Server cannot initiate a conversation with the client.
                                 11
WEB SERVICES PROTOCOL
 The Web Services Protocol:

    The client decides it needs to ask the server for some information
     It constructs the relevant XML based web services query (either
     dynamically or in a static fashion depending on the complexity of the
     application)‫‏‬

    It then connects to the Web Service Server

       Pushing the web request up as an HTTP 'Post' request

       It waits for a response

    The Web service server then 'Posts' back an XML payload representing
     the answer

    The client then unpacks and interprets the data.
                                      12
THIS SOUNDS HARD...

•   Not really.

    •   Its a combination of web protocol and XML construction and
        unpacking

    •   Most of the hard work is done for you by the various Web Service
        servers and Consumers

    •   Its fairly easy to debug using the correct tools

                                        13
A SAMPLE APPLICATION
•   Fairly simple Domino Contact Database

    •   A single ‘Contact’ form with some information

    •   Not meant to be a ‘real-world’ example - Its here to demonstrate
        the techniques

•   All example code is in the database

    •   Simple to figure out and ‘research’

    •   Probably isn’t best practice!

                                        14
EXAMPLE DATABASE:




        15
EXAMPLE DATABASE:
  CONTACTS.NSF




        16
HOW DO WE TEST A WEB
         SERVICE?
•   I recommend SoapUI

    •   Its free!

    •   http://www.soapui.org

•   It allows you to interrogate a web service

    •   And build test case with real data



                                    17
SOAPUI: EXAMPLE
  SCREENSHOT




       18
DOMINO WEB SERVICE SERVER

•   By far the simplest is to use a LotusScript Web Service

    •   The majority of the work is done for you!

•   Servlets should be avoided unless

    •   You are running on Domino v6.5.x or older

    •   You absolutely require persistence



                                   20
LOTUSSCRIPT WEB SERVICES
•   Introduced in Lotus Domino 7

•   Robust

•   Code the web service using LotusScript

•   Fairly high performance but

    •   Remember: Lack of persistence between calls, so

        •   Be aware of what your code is doing!

        •   Use ‘Agent Profiling’ to see timings…
                                    21
PROFILING A WEB SERVICE
•   LotusScript web services are
    very similar to LotusScript agents

    •   So you can profile them.

    •   Enable Profiling on the Web
        Services Properties tab

    •   View the last run profile:

        •   Right click on the Web Service

        •   View Profile Results	


                                     22
A SAMPLE PROFILE
•   This shows how long the agent took to run, and how long the
    agent spent inside the Notes Object Interface

    •   In our case, 761ms total, and 0ms within NOI

    •   One call to CurrentDatabase, and one call to Title.




                                   23
DESIGNING A WEB SERVICE

•   Spend time thinking about how your consumer will use this web
    service.

    •   More time thinking, less time coding

    •   You do NOT want to change this web service interface once its
        published

        •   Instead - roll out a new web service

    •   Think through client use cases
                                         24
CONTACTS.NSF
•   In our case we wish to:

    •   Be able to list all users by Name, by Department

    •   Be able to get details on a particular user

    •   Be able to search for users

•   Do we

    •   Pass all fields back as web service items?

    •   Pass back an array of fields?

•   In this case, we pass back Web Service Items

    •   Assume data mapping knowledge and responsibility.
                                25
WEB SERVICE DESIGN
•   We design our web service interface within a ‘Class’ in
    LotusScript.

    •   At this point, you probably wished that you studied the
        Object Orientated LotusScript sessions I used to give…

•   Our web service will expose all ‘public’ methods and properties

    •   We do not have to put all the code in one ‘class’

    •   Beware of extending existing classes - you might expose
        more than you want!

        •   Beware over-exposure…
                                   26
WEB SERVICE DESIGN
•   LotusScript does NOT allow functions to return Arrays.

    •   This is a language limitation, not a Web Service Limitation

    •   It can return simple types - but not variants (web services
        don’t support ‘em)

    •   Instances of other classes…

•   We need to use arrays to return results

    •   For instance, we need to return an array of Zero or more
        entries to list our users. How do we do that?

•   We can define a class and return an instance of that class…
                                    27
RETURNING COMPLEX TYPES
                                           Class returnArray

                                                Public S() As String
•   We can define a class called
    ‘ReturnArray’ which has a single            Sub new
    array as a public member.
                                                  Redim S(0)
    •   The constructor initialises the
                                                  S(0) = ""
        array so that it has one blank entry.
                                                End Sub
•   We can then populate this array
    with one or more entries.              End Class

•   Nd7 supports arrays with one
    element or more - nd8 supports ‘empty’ arrays.

                                    28
COMPLEX TYPES…
                                                  Class Person
•   We shall return our Person contact
    record using a class.                         	

   Public FirstName As String
                                                  	

   Public MiddleInitials As String
                                                  	

   Public LastName As String
    •   We DON’T have a constructor               	

   Public FullName As String

    •   All elements are Public - so it’ll        	

   Public Telephone As String
                                                  	

   Public Cellphone As String
        be exposed to the Web Service             	

   Public eMail As String
        as data.                                  	

   Public HomePhone As String
                                                  	

   Public Department as String
    •   Our property names will be
        used by the web service as field           	

   Public Notes As String
        names
                                                  End Class

    •   Since LotusScript is case
        insensitive, the web service field
        names will be UPPERCASE.
                                             29
LETS MAKE IT BETTER
•   We need to add:

    •   Logging. We need to know when it works, and importantly,
        when it does not

    •   Error Handling. We need to pass errors back to the consumer

    •   Security. We might want to harden this service somewhat

•   We committed the following sins:

    •   We put all the code in the web service itself, making it hard
        to test. Best to consider embedding most of the code in script
        libraries

    •   We’ve tightly bound the data structures in our data to our
        web service
                                   30
ND7 AND ND8 DIFFERENCES
•   Web services built or compiled in Notes 8 Designer WONT
    run on ND7 anymore!




    So be careful about what web services you host on which
    servers, and which version of designer you use.

    •   Just bear this version difference in the same manner as all
        other version differences.

                                    31
ND7 AND ND8 DIFFERENCES
•   In ND7, the class used for the web service has to reside in the
    web service design element. In ND8, this can be in a script
    library.

    •   This means that for complex services, you can place all the
        business code in a script library, allowing simple construction
        of a test harness.

•   ND8 now supports code in Java Libraries

•   ND8 supports more error handling SOAP elements

•   ND8 supports ‘empty’ arrays - nd7 does not

                                    32
CONSUMING A WEB SERVICE
•   Why consume web services?

    •   To gain access to information in other systems

    •   To prevent the synchronisation and replication of external data sources to
        Notes

    •   Real time, up to date data lookup

•   Where?

    •   We could use a scheduled Java agent in Domino to interrogate external
        services - no UI means you have to monitor and check

    •   We could use client-driven code on the client workstation - be aware of
        network issues between the clients and the remote service

                                            34
OVERVIEW
•   Security

    •   Remote web services may require

        •   Username/password login, Encrypted username/password
            pairs in data, SSL.

•   Things change

    •   You may have to change your web service consumer to
        accommodate this

    •   The remote web service may move

    •   When designing, don’t hard-code…
                                  35
CONSUMING WEB SERVICES
•   Summary:

    •   Notes 8 - Its very simple - It works in LotusScript and in Java

    •   It does a lot of work for you

•   How do I construct a Web Service Consumer in LotusScript?

    •   Create a new, empty script library

    •   Click on the Import WSDL button

    •   It creates a Class definition

    •   You can then “use” the script library and class.
                                       36
CONSUMING WEB SERVICES
•   On the nd8 basic client: create a new LotusScript Script Library:




•   Click on the WSDL button…

                                  37
CONSUMING WEB SERVICES



•   On nd8 standard
    designer, go to
    Code, Web services
    consumer
CONSUMING WEB SERVICES

•   Click on ‘New Web service consumer’ and fill in the dialog:
CONSUMING WEB SERVICES

•   And then use the web service consumer library that has been
    created:
CONSUMING WEB SERVICES
•   It needs a WSDL file. What's that?

    •   You can open the WSDL
        definition for your web
        service in your browser
                                            Sub Initialize
    •   Use View Source, and save that as
        a WSDL file.                         	

   Dim C As New Contacts

                                            	

    •   Select it…                          	

   Dim V As Variant
                                            	

   Set V = C.listUsers()
•   Designer will then construct            	

   Forall thisUser In V.S
    helper classes and a main               	

   	

  Print "Found User: " + thisUser
                                            	

   End Forall
    class which we can then call
                                            End Sub
•   That’s it!
                                   41
GOTCHAS
•   The entire LotusScript library is taken up with the computed
    Web service definition. Best not to make changes.

    •   Next time its refreshed, you will lose those changes!

•   If you change the web service, you must remember to update
    the Web Services consumer.

    •   It doesn’t take long - so don’t forget it.

    •   And when you change the web service consumer script
        library, you must recompile all the LotusScript that relies on
        it.

        •   ‘Tools, Recompile LotusScript’ is your friend
                                      42
GOTCHAS
•   It requires the Notes 8 client to run on:

    •   We as Application Developers deploy solutions on users’
        target notes clients

    •   Notes 8 may not yet be adopted in your environment

    •   This may help drive the upgrade process

•   What if you need Web Service consumption now, and are not
    yet on Notes 8?

    •   You can use MS COM objects.

                                   43
SUMMARY

•   Web Services

    •   Are pretty straightforward

    •   An important part of your armoury

    •   Help break down barriers between Domino and other systems

    •   Help prevent data duplication in your environment
QUESTIONS AND ANSWERS ?



•   Please fill out your evaluations:

•   Thank you for your time today

Weitere ähnliche Inhalte

Was ist angesagt?

Consuming RESTful services in PHP
Consuming RESTful services in PHPConsuming RESTful services in PHP
Consuming RESTful services in PHPZoran Jeremic
 
Web services - A Practical Approach
Web services - A Practical ApproachWeb services - A Practical Approach
Web services - A Practical ApproachMadhaiyan Muthu
 
- Domain Booking - Hosting
- Domain Booking - Hosting - Domain Booking - Hosting
- Domain Booking - Hosting webhostingguy
 
Cloud computing by Luqman
Cloud computing by LuqmanCloud computing by Luqman
Cloud computing by LuqmanLuqman Shareef
 
Service Oriented Architecture Luqman
Service Oriented Architecture LuqmanService Oriented Architecture Luqman
Service Oriented Architecture LuqmanLuqman Shareef
 
Jim Webber A Couple Of Ways To Skin An Internet Scale Catx
Jim Webber A Couple Of Ways To Skin An Internet Scale CatxJim Webber A Couple Of Ways To Skin An Internet Scale Catx
Jim Webber A Couple Of Ways To Skin An Internet Scale Catxdeimos
 
Webservices Workshop - september 2014
Webservices Workshop -  september 2014Webservices Workshop -  september 2014
Webservices Workshop - september 2014clairvoyantllc
 
Speed in the Opera mobile browsers
Speed in the Opera mobile browsersSpeed in the Opera mobile browsers
Speed in the Opera mobile browsersgerbille
 
Fast & Scalable Front/Back-ends using Ruby, Rails & XMPP
Fast & Scalable Front/Back-ends using Ruby, Rails & XMPPFast & Scalable Front/Back-ends using Ruby, Rails & XMPP
Fast & Scalable Front/Back-ends using Ruby, Rails & XMPPPradeep Elankumaran
 
Real-time Web with Rails and XMPP
Real-time Web with Rails and XMPPReal-time Web with Rails and XMPP
Real-time Web with Rails and XMPPLi Cai
 
PHP: Best Mailing Practices
PHP: Best Mailing PracticesPHP: Best Mailing Practices
PHP: Best Mailing Practiceswebhostingguy
 
Understanding the Web through HTTP
Understanding the Web through HTTPUnderstanding the Web through HTTP
Understanding the Web through HTTPOlivia Brundage
 
HTML5 Server Sent Events/JSF JAX 2011 Conference
HTML5 Server Sent Events/JSF  JAX 2011 ConferenceHTML5 Server Sent Events/JSF  JAX 2011 Conference
HTML5 Server Sent Events/JSF JAX 2011 ConferenceRoger Kitain
 
21 Www Web Services
21 Www Web Services21 Www Web Services
21 Www Web Servicesroyans
 
Indroduction to Web Application
Indroduction to Web ApplicationIndroduction to Web Application
Indroduction to Web Applicationtorny10
 

Was ist angesagt? (18)

Web Services
Web ServicesWeb Services
Web Services
 
Domain Name
Domain NameDomain Name
Domain Name
 
Consuming RESTful services in PHP
Consuming RESTful services in PHPConsuming RESTful services in PHP
Consuming RESTful services in PHP
 
Web services - A Practical Approach
Web services - A Practical ApproachWeb services - A Practical Approach
Web services - A Practical Approach
 
- Domain Booking - Hosting
- Domain Booking - Hosting - Domain Booking - Hosting
- Domain Booking - Hosting
 
Cloud computing by Luqman
Cloud computing by LuqmanCloud computing by Luqman
Cloud computing by Luqman
 
Service Oriented Architecture Luqman
Service Oriented Architecture LuqmanService Oriented Architecture Luqman
Service Oriented Architecture Luqman
 
Jim Webber A Couple Of Ways To Skin An Internet Scale Catx
Jim Webber A Couple Of Ways To Skin An Internet Scale CatxJim Webber A Couple Of Ways To Skin An Internet Scale Catx
Jim Webber A Couple Of Ways To Skin An Internet Scale Catx
 
Webservices Workshop - september 2014
Webservices Workshop -  september 2014Webservices Workshop -  september 2014
Webservices Workshop - september 2014
 
Speed in the Opera mobile browsers
Speed in the Opera mobile browsersSpeed in the Opera mobile browsers
Speed in the Opera mobile browsers
 
Fast & Scalable Front/Back-ends using Ruby, Rails & XMPP
Fast & Scalable Front/Back-ends using Ruby, Rails & XMPPFast & Scalable Front/Back-ends using Ruby, Rails & XMPP
Fast & Scalable Front/Back-ends using Ruby, Rails & XMPP
 
Real-time Web with Rails and XMPP
Real-time Web with Rails and XMPPReal-time Web with Rails and XMPP
Real-time Web with Rails and XMPP
 
PHP: Best Mailing Practices
PHP: Best Mailing PracticesPHP: Best Mailing Practices
PHP: Best Mailing Practices
 
Web Services Tutorial
Web Services TutorialWeb Services Tutorial
Web Services Tutorial
 
Understanding the Web through HTTP
Understanding the Web through HTTPUnderstanding the Web through HTTP
Understanding the Web through HTTP
 
HTML5 Server Sent Events/JSF JAX 2011 Conference
HTML5 Server Sent Events/JSF  JAX 2011 ConferenceHTML5 Server Sent Events/JSF  JAX 2011 Conference
HTML5 Server Sent Events/JSF JAX 2011 Conference
 
21 Www Web Services
21 Www Web Services21 Www Web Services
21 Www Web Services
 
Indroduction to Web Application
Indroduction to Web ApplicationIndroduction to Web Application
Indroduction to Web Application
 

Ähnlich wie Nllug 2010 - Web-services bootcamp

iLug 2008 Web Services
iLug 2008 Web ServicesiLug 2008 Web Services
iLug 2008 Web ServicesBill Buchan
 
SOA with Zend Framework
SOA with Zend FrameworkSOA with Zend Framework
SOA with Zend FrameworkMike Willbanks
 
Lotusphere 2008 - Jumpstart 206 - Web Services Bootcamp
Lotusphere 2008 - Jumpstart 206 - Web Services BootcampLotusphere 2008 - Jumpstart 206 - Web Services Bootcamp
Lotusphere 2008 - Jumpstart 206 - Web Services BootcampBill Buchan
 
What is Node.js? (ICON UK)
What is Node.js? (ICON UK)What is Node.js? (ICON UK)
What is Node.js? (ICON UK)Tim Davis
 
Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3Wen-Tien Chang
 
Jmp206 Web Services Bootcamp Final Draft
Jmp206   Web Services Bootcamp Final DraftJmp206   Web Services Bootcamp Final Draft
Jmp206 Web Services Bootcamp Final DraftBill Buchan
 
The View - Leveraging Lotuscript for Database Connectivity
The View - Leveraging Lotuscript for Database ConnectivityThe View - Leveraging Lotuscript for Database Connectivity
The View - Leveraging Lotuscript for Database ConnectivityBill Buchan
 
Scaling on AWS for the First 10 Million Users
Scaling on AWS for the First 10 Million UsersScaling on AWS for the First 10 Million Users
Scaling on AWS for the First 10 Million UsersAmazon Web Services
 
Advanced Web Technology.pptx
Advanced Web Technology.pptxAdvanced Web Technology.pptx
Advanced Web Technology.pptxssuser35fdf2
 
Portal / BI 2008 Presentation by Ted Tschopp
Portal / BI 2008 Presentation by Ted TschoppPortal / BI 2008 Presentation by Ted Tschopp
Portal / BI 2008 Presentation by Ted TschoppTed Tschopp
 
MJ Berends talk - Women & Non-Binary Focused Intro to AWS
 MJ Berends talk - Women & Non-Binary Focused Intro to AWS MJ Berends talk - Women & Non-Binary Focused Intro to AWS
MJ Berends talk - Women & Non-Binary Focused Intro to AWSAWS Chicago
 
SmugMug: From MySQL to Amazon DynamoDB (DAT204) | AWS re:Invent 2013
SmugMug: From MySQL to Amazon DynamoDB (DAT204) | AWS re:Invent 2013SmugMug: From MySQL to Amazon DynamoDB (DAT204) | AWS re:Invent 2013
SmugMug: From MySQL to Amazon DynamoDB (DAT204) | AWS re:Invent 2013Amazon Web Services
 
Untangling spring week11
Untangling spring week11Untangling spring week11
Untangling spring week11Derek Jacoby
 
JSR 335 / java 8 - update reference
JSR 335 / java 8 - update referenceJSR 335 / java 8 - update reference
JSR 335 / java 8 - update referencesandeepji_choudhary
 
How to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless EditionHow to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless EditionLecole Cole
 
How to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless EditionHow to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless Editionecobold
 
Designing your API Server for mobile apps
Designing your API Server for mobile appsDesigning your API Server for mobile apps
Designing your API Server for mobile appsMugunth Kumar
 
[Annotated] QConSF 2018: Airbnb's Great Migration - From Monolith to Service-...
[Annotated] QConSF 2018: Airbnb's Great Migration - From Monolith to Service-...[Annotated] QConSF 2018: Airbnb's Great Migration - From Monolith to Service-...
[Annotated] QConSF 2018: Airbnb's Great Migration - From Monolith to Service-...Jessica Tai
 

Ähnlich wie Nllug 2010 - Web-services bootcamp (20)

iLug 2008 Web Services
iLug 2008 Web ServicesiLug 2008 Web Services
iLug 2008 Web Services
 
SOA with Zend Framework
SOA with Zend FrameworkSOA with Zend Framework
SOA with Zend Framework
 
Lotusphere 2008 - Jumpstart 206 - Web Services Bootcamp
Lotusphere 2008 - Jumpstart 206 - Web Services BootcampLotusphere 2008 - Jumpstart 206 - Web Services Bootcamp
Lotusphere 2008 - Jumpstart 206 - Web Services Bootcamp
 
What is Node.js? (ICON UK)
What is Node.js? (ICON UK)What is Node.js? (ICON UK)
What is Node.js? (ICON UK)
 
Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3Service-Oriented Design and Implement with Rails3
Service-Oriented Design and Implement with Rails3
 
Jmp206 Web Services Bootcamp Final Draft
Jmp206   Web Services Bootcamp Final DraftJmp206   Web Services Bootcamp Final Draft
Jmp206 Web Services Bootcamp Final Draft
 
The View - Leveraging Lotuscript for Database Connectivity
The View - Leveraging Lotuscript for Database ConnectivityThe View - Leveraging Lotuscript for Database Connectivity
The View - Leveraging Lotuscript for Database Connectivity
 
Scaling on AWS for the First 10 Million Users
Scaling on AWS for the First 10 Million UsersScaling on AWS for the First 10 Million Users
Scaling on AWS for the First 10 Million Users
 
Advanced Web Technology.pptx
Advanced Web Technology.pptxAdvanced Web Technology.pptx
Advanced Web Technology.pptx
 
Portal / BI 2008 Presentation by Ted Tschopp
Portal / BI 2008 Presentation by Ted TschoppPortal / BI 2008 Presentation by Ted Tschopp
Portal / BI 2008 Presentation by Ted Tschopp
 
MJ Berends talk - Women & Non-Binary Focused Intro to AWS
 MJ Berends talk - Women & Non-Binary Focused Intro to AWS MJ Berends talk - Women & Non-Binary Focused Intro to AWS
MJ Berends talk - Women & Non-Binary Focused Intro to AWS
 
SmugMug: From MySQL to Amazon DynamoDB (DAT204) | AWS re:Invent 2013
SmugMug: From MySQL to Amazon DynamoDB (DAT204) | AWS re:Invent 2013SmugMug: From MySQL to Amazon DynamoDB (DAT204) | AWS re:Invent 2013
SmugMug: From MySQL to Amazon DynamoDB (DAT204) | AWS re:Invent 2013
 
Untangling spring week11
Untangling spring week11Untangling spring week11
Untangling spring week11
 
JSR 335 / java 8 - update reference
JSR 335 / java 8 - update referenceJSR 335 / java 8 - update reference
JSR 335 / java 8 - update reference
 
ACM Init() lesson 1
ACM Init() lesson 1ACM Init() lesson 1
ACM Init() lesson 1
 
How to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless EditionHow to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless Edition
 
Windows Azure introduction
Windows Azure introductionWindows Azure introduction
Windows Azure introduction
 
How to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless EditionHow to Build a Big Data Application: Serverless Edition
How to Build a Big Data Application: Serverless Edition
 
Designing your API Server for mobile apps
Designing your API Server for mobile appsDesigning your API Server for mobile apps
Designing your API Server for mobile apps
 
[Annotated] QConSF 2018: Airbnb's Great Migration - From Monolith to Service-...
[Annotated] QConSF 2018: Airbnb's Great Migration - From Monolith to Service-...[Annotated] QConSF 2018: Airbnb's Great Migration - From Monolith to Service-...
[Annotated] QConSF 2018: Airbnb's Great Migration - From Monolith to Service-...
 

Mehr von Bill Buchan

Dummies guide to WISPS
Dummies guide to WISPSDummies guide to WISPS
Dummies guide to WISPSBill Buchan
 
WISP for Dummies
WISP for DummiesWISP for Dummies
WISP for DummiesBill Buchan
 
WISP Worst Practices
WISP Worst PracticesWISP Worst Practices
WISP Worst PracticesBill Buchan
 
Marykirk raft race presentation night 2014
Marykirk raft race presentation night 2014Marykirk raft race presentation night 2014
Marykirk raft race presentation night 2014Bill Buchan
 
Dev buchan best practices
Dev buchan best practicesDev buchan best practices
Dev buchan best practicesBill Buchan
 
Dev buchan leveraging
Dev buchan leveragingDev buchan leveraging
Dev buchan leveragingBill Buchan
 
Dev buchan leveraging the notes c api
Dev buchan leveraging the notes c apiDev buchan leveraging the notes c api
Dev buchan leveraging the notes c apiBill Buchan
 
Dev buchan everything you need to know about agent design
Dev buchan everything you need to know about agent designDev buchan everything you need to know about agent design
Dev buchan everything you need to know about agent designBill Buchan
 
Dev buchan 30 proven tips
Dev buchan 30 proven tipsDev buchan 30 proven tips
Dev buchan 30 proven tipsBill Buchan
 
Entwicker camp2007 calling-the-c-api-from-lotusscript
Entwicker camp2007 calling-the-c-api-from-lotusscriptEntwicker camp2007 calling-the-c-api-from-lotusscript
Entwicker camp2007 calling-the-c-api-from-lotusscriptBill Buchan
 
Entwicker camp2007 blackberry-workshop
Entwicker camp2007 blackberry-workshopEntwicker camp2007 blackberry-workshop
Entwicker camp2007 blackberry-workshopBill Buchan
 
Reporting on your domino environment v1
Reporting on your domino environment v1Reporting on your domino environment v1
Reporting on your domino environment v1Bill Buchan
 
12 Step Guide to Lotuscript
12 Step Guide to Lotuscript12 Step Guide to Lotuscript
12 Step Guide to LotuscriptBill Buchan
 
Everything you ever wanted to know about lotus script
Everything you ever wanted to know about lotus scriptEverything you ever wanted to know about lotus script
Everything you ever wanted to know about lotus scriptBill Buchan
 
Admin camp 2011-domino-sso-with-ad
Admin camp 2011-domino-sso-with-adAdmin camp 2011-domino-sso-with-ad
Admin camp 2011-domino-sso-with-adBill Buchan
 
Connections Lotusphere Worst Practices 2013
Connections Lotusphere Worst Practices 2013Connections Lotusphere Worst Practices 2013
Connections Lotusphere Worst Practices 2013Bill Buchan
 
Lotusphere 2009 The 11 Commandments
Lotusphere 2009 The 11 CommandmentsLotusphere 2009 The 11 Commandments
Lotusphere 2009 The 11 CommandmentsBill Buchan
 

Mehr von Bill Buchan (20)

Dummies guide to WISPS
Dummies guide to WISPSDummies guide to WISPS
Dummies guide to WISPS
 
WISP for Dummies
WISP for DummiesWISP for Dummies
WISP for Dummies
 
WISP Worst Practices
WISP Worst PracticesWISP Worst Practices
WISP Worst Practices
 
Marykirk raft race presentation night 2014
Marykirk raft race presentation night 2014Marykirk raft race presentation night 2014
Marykirk raft race presentation night 2014
 
Dev buchan best practices
Dev buchan best practicesDev buchan best practices
Dev buchan best practices
 
Dev buchan leveraging
Dev buchan leveragingDev buchan leveraging
Dev buchan leveraging
 
Dev buchan leveraging the notes c api
Dev buchan leveraging the notes c apiDev buchan leveraging the notes c api
Dev buchan leveraging the notes c api
 
Dev buchan everything you need to know about agent design
Dev buchan everything you need to know about agent designDev buchan everything you need to know about agent design
Dev buchan everything you need to know about agent design
 
Dev buchan 30 proven tips
Dev buchan 30 proven tipsDev buchan 30 proven tips
Dev buchan 30 proven tips
 
Entwicker camp2007 calling-the-c-api-from-lotusscript
Entwicker camp2007 calling-the-c-api-from-lotusscriptEntwicker camp2007 calling-the-c-api-from-lotusscript
Entwicker camp2007 calling-the-c-api-from-lotusscript
 
Entwicker camp2007 blackberry-workshop
Entwicker camp2007 blackberry-workshopEntwicker camp2007 blackberry-workshop
Entwicker camp2007 blackberry-workshop
 
Bp301
Bp301Bp301
Bp301
 
Ad507
Ad507Ad507
Ad507
 
Ad505 dev blast
Ad505 dev blastAd505 dev blast
Ad505 dev blast
 
Reporting on your domino environment v1
Reporting on your domino environment v1Reporting on your domino environment v1
Reporting on your domino environment v1
 
12 Step Guide to Lotuscript
12 Step Guide to Lotuscript12 Step Guide to Lotuscript
12 Step Guide to Lotuscript
 
Everything you ever wanted to know about lotus script
Everything you ever wanted to know about lotus scriptEverything you ever wanted to know about lotus script
Everything you ever wanted to know about lotus script
 
Admin camp 2011-domino-sso-with-ad
Admin camp 2011-domino-sso-with-adAdmin camp 2011-domino-sso-with-ad
Admin camp 2011-domino-sso-with-ad
 
Connections Lotusphere Worst Practices 2013
Connections Lotusphere Worst Practices 2013Connections Lotusphere Worst Practices 2013
Connections Lotusphere Worst Practices 2013
 
Lotusphere 2009 The 11 Commandments
Lotusphere 2009 The 11 CommandmentsLotusphere 2009 The 11 Commandments
Lotusphere 2009 The 11 Commandments
 

Nllug 2010 - Web-services bootcamp

  • 1. WEB SERVICES BOOTCAMP Bill Buchan - HADSL
  • 2. AGENDA • Introduction • Web Services Overview • Using Domino to provide Web Services • Using Notes to consume Web Services • Summary, Q+A
  • 3.
  • 4. INTRODUCTION • I am Bill Buchan. I am: • A blogger - http://www.billbuchan.com • I was blogging when it was called ‘Talking rubbish on the internet’. • Some things never change. • A principal of HADSL - http://www.hadsl.com
  • 5. WE DO COMPLICATED STUFF • Our product deals with enterprise user and resource/service management • Continually pushing the Notes platform • Currently coding around the OOO and ID Vault API’s • All my presentations are based on the work we do in FirM
  • 6. LOTS OF CONTENT HERE • This takes you from a low level in a subject to a good level of expertise • Little existing knowledge is assumed • But we assume your are developers, and are familiar with LotusScript • No xPages, Java • This is a 2 hour presentation, squeezed into 45 minutes • This will be fast 6
  • 7. I HAD THE PLEASURE • Of working in Holland for many years • Be gentle! • Questions at the end...
  • 8.
  • 9. A QUICK OVERVIEW • Web services are: • A standard application to application protocol for exchanging structured data • Usually (but not always) using the http protocol • Usually (but not always) using XML • Usually we provide meta-information on what our service will do, using a language called WSDL (Web Service Description Language) – formatted in XML. • Web services are Language independent, Platform independent, Data format representation independent • But hopefully you all knew this already...
  • 10. WEB SERVICES ARCHITECTURE • The players: • The Web Service server • Can answer questions on what it can do • Can accept requests from Web Service clients • Can respond to requests from Web service clients
  • 11. WEB SERVICES PROTOCOL  A typical web service session looks like: Client to Web Service Server  “Tell me the answer to this question” Web Service Server  “Here it is”  Conclusion: The clients drive the conversation The Server cannot initiate a conversation with the client. 11
  • 12. WEB SERVICES PROTOCOL  The Web Services Protocol:  The client decides it needs to ask the server for some information It constructs the relevant XML based web services query (either dynamically or in a static fashion depending on the complexity of the application)‫‏‬  It then connects to the Web Service Server  Pushing the web request up as an HTTP 'Post' request  It waits for a response  The Web service server then 'Posts' back an XML payload representing the answer  The client then unpacks and interprets the data. 12
  • 13. THIS SOUNDS HARD... • Not really. • Its a combination of web protocol and XML construction and unpacking • Most of the hard work is done for you by the various Web Service servers and Consumers • Its fairly easy to debug using the correct tools 13
  • 14. A SAMPLE APPLICATION • Fairly simple Domino Contact Database • A single ‘Contact’ form with some information • Not meant to be a ‘real-world’ example - Its here to demonstrate the techniques • All example code is in the database • Simple to figure out and ‘research’ • Probably isn’t best practice! 14
  • 16. EXAMPLE DATABASE: CONTACTS.NSF 16
  • 17. HOW DO WE TEST A WEB SERVICE? • I recommend SoapUI • Its free! • http://www.soapui.org • It allows you to interrogate a web service • And build test case with real data 17
  • 18. SOAPUI: EXAMPLE SCREENSHOT 18
  • 19.
  • 20. DOMINO WEB SERVICE SERVER • By far the simplest is to use a LotusScript Web Service • The majority of the work is done for you! • Servlets should be avoided unless • You are running on Domino v6.5.x or older • You absolutely require persistence 20
  • 21. LOTUSSCRIPT WEB SERVICES • Introduced in Lotus Domino 7 • Robust • Code the web service using LotusScript • Fairly high performance but • Remember: Lack of persistence between calls, so • Be aware of what your code is doing! • Use ‘Agent Profiling’ to see timings… 21
  • 22. PROFILING A WEB SERVICE • LotusScript web services are very similar to LotusScript agents • So you can profile them. • Enable Profiling on the Web Services Properties tab • View the last run profile: • Right click on the Web Service • View Profile Results 22
  • 23. A SAMPLE PROFILE • This shows how long the agent took to run, and how long the agent spent inside the Notes Object Interface • In our case, 761ms total, and 0ms within NOI • One call to CurrentDatabase, and one call to Title. 23
  • 24. DESIGNING A WEB SERVICE • Spend time thinking about how your consumer will use this web service. • More time thinking, less time coding • You do NOT want to change this web service interface once its published • Instead - roll out a new web service • Think through client use cases 24
  • 25. CONTACTS.NSF • In our case we wish to: • Be able to list all users by Name, by Department • Be able to get details on a particular user • Be able to search for users • Do we • Pass all fields back as web service items? • Pass back an array of fields? • In this case, we pass back Web Service Items • Assume data mapping knowledge and responsibility. 25
  • 26. WEB SERVICE DESIGN • We design our web service interface within a ‘Class’ in LotusScript. • At this point, you probably wished that you studied the Object Orientated LotusScript sessions I used to give… • Our web service will expose all ‘public’ methods and properties • We do not have to put all the code in one ‘class’ • Beware of extending existing classes - you might expose more than you want! • Beware over-exposure… 26
  • 27. WEB SERVICE DESIGN • LotusScript does NOT allow functions to return Arrays. • This is a language limitation, not a Web Service Limitation • It can return simple types - but not variants (web services don’t support ‘em) • Instances of other classes… • We need to use arrays to return results • For instance, we need to return an array of Zero or more entries to list our users. How do we do that? • We can define a class and return an instance of that class… 27
  • 28. RETURNING COMPLEX TYPES Class returnArray Public S() As String • We can define a class called ‘ReturnArray’ which has a single Sub new array as a public member. Redim S(0) • The constructor initialises the S(0) = "" array so that it has one blank entry. End Sub • We can then populate this array with one or more entries. End Class • Nd7 supports arrays with one element or more - nd8 supports ‘empty’ arrays. 28
  • 29. COMPLEX TYPES… Class Person • We shall return our Person contact record using a class. Public FirstName As String Public MiddleInitials As String Public LastName As String • We DON’T have a constructor Public FullName As String • All elements are Public - so it’ll Public Telephone As String Public Cellphone As String be exposed to the Web Service Public eMail As String as data. Public HomePhone As String Public Department as String • Our property names will be used by the web service as field Public Notes As String names End Class • Since LotusScript is case insensitive, the web service field names will be UPPERCASE. 29
  • 30. LETS MAKE IT BETTER • We need to add: • Logging. We need to know when it works, and importantly, when it does not • Error Handling. We need to pass errors back to the consumer • Security. We might want to harden this service somewhat • We committed the following sins: • We put all the code in the web service itself, making it hard to test. Best to consider embedding most of the code in script libraries • We’ve tightly bound the data structures in our data to our web service 30
  • 31. ND7 AND ND8 DIFFERENCES • Web services built or compiled in Notes 8 Designer WONT run on ND7 anymore! So be careful about what web services you host on which servers, and which version of designer you use. • Just bear this version difference in the same manner as all other version differences. 31
  • 32. ND7 AND ND8 DIFFERENCES • In ND7, the class used for the web service has to reside in the web service design element. In ND8, this can be in a script library. • This means that for complex services, you can place all the business code in a script library, allowing simple construction of a test harness. • ND8 now supports code in Java Libraries • ND8 supports more error handling SOAP elements • ND8 supports ‘empty’ arrays - nd7 does not 32
  • 33.
  • 34. CONSUMING A WEB SERVICE • Why consume web services? • To gain access to information in other systems • To prevent the synchronisation and replication of external data sources to Notes • Real time, up to date data lookup • Where? • We could use a scheduled Java agent in Domino to interrogate external services - no UI means you have to monitor and check • We could use client-driven code on the client workstation - be aware of network issues between the clients and the remote service 34
  • 35. OVERVIEW • Security • Remote web services may require • Username/password login, Encrypted username/password pairs in data, SSL. • Things change • You may have to change your web service consumer to accommodate this • The remote web service may move • When designing, don’t hard-code… 35
  • 36. CONSUMING WEB SERVICES • Summary: • Notes 8 - Its very simple - It works in LotusScript and in Java • It does a lot of work for you • How do I construct a Web Service Consumer in LotusScript? • Create a new, empty script library • Click on the Import WSDL button • It creates a Class definition • You can then “use” the script library and class. 36
  • 37. CONSUMING WEB SERVICES • On the nd8 basic client: create a new LotusScript Script Library: • Click on the WSDL button… 37
  • 38. CONSUMING WEB SERVICES • On nd8 standard designer, go to Code, Web services consumer
  • 39. CONSUMING WEB SERVICES • Click on ‘New Web service consumer’ and fill in the dialog:
  • 40. CONSUMING WEB SERVICES • And then use the web service consumer library that has been created:
  • 41. CONSUMING WEB SERVICES • It needs a WSDL file. What's that? • You can open the WSDL definition for your web service in your browser Sub Initialize • Use View Source, and save that as a WSDL file. Dim C As New Contacts • Select it… Dim V As Variant Set V = C.listUsers() • Designer will then construct Forall thisUser In V.S helper classes and a main Print "Found User: " + thisUser End Forall class which we can then call End Sub • That’s it! 41
  • 42. GOTCHAS • The entire LotusScript library is taken up with the computed Web service definition. Best not to make changes. • Next time its refreshed, you will lose those changes! • If you change the web service, you must remember to update the Web Services consumer. • It doesn’t take long - so don’t forget it. • And when you change the web service consumer script library, you must recompile all the LotusScript that relies on it. • ‘Tools, Recompile LotusScript’ is your friend 42
  • 43. GOTCHAS • It requires the Notes 8 client to run on: • We as Application Developers deploy solutions on users’ target notes clients • Notes 8 may not yet be adopted in your environment • This may help drive the upgrade process • What if you need Web Service consumption now, and are not yet on Notes 8? • You can use MS COM objects. 43
  • 44. SUMMARY • Web Services • Are pretty straightforward • An important part of your armoury • Help break down barriers between Domino and other systems • Help prevent data duplication in your environment
  • 45.
  • 46. QUESTIONS AND ANSWERS ? • Please fill out your evaluations: • Thank you for your time today