web services with delphi, sep, 2008
DESCRIPTION
Describes the steps necessary to build web services (both server-side and client-side) in Delphi.TRANSCRIPT
Oregon Delphi User GroupSeptember, 2008
What are web services—very brieflyRemotely invokable methods with a pre-defined
APIParameters (object with properties)Return values (object with properties)SOAP XML via HTTP
Another way of saying it…“Web Services, in the general meaning of the term, are processes offered via the Web. In a typical Web Services scenario, a business application sends a request to a service at a given URL using the SOAP protocol over HTTP. The service receives the request, processes it, and returns a response.” –Harms Software
2ODUG - Web Services, Sep 2008
Single store, one database, simple accounting.
3ODUG - Web Services, Sep 2008
Add an ecommerce web site.
Two databases—accountant is not happy.Shipping department confused.Customers can “buy” out-of-stock items.
4ODUG - Web Services, Sep 2008
Need to merge—but how?
5ODUG - Web Services, Sep 2008
The answer of course for today:Web Services!
6ODUG - Web Services, Sep 2008
What is needed here?Web site needs to know what inventory is
availableStore needs to collect order informationStore needs to adjust inventory levelsStore needs to ship productsStore needs to notify web site of order statusWeb site needs to display order status
7ODUG - Web Services, Sep 2008
Possible web service methods:UpdateInventory
Adds or updates items to web databaseGetPendingOrders
Get list of orders pending from webGet single order details from web
UpdateOrderStatusUpdate status field and tracking number on web
8ODUG - Web Services, Sep 2008
File > NewOther > Web Services > SOAP Server
ApplicationThree types
ISAPI .DLLCGI Stand-alone .EXEWeb App Debugger
Create an interfaceFile > new
Other > Web Services > SOAP Server Interface
9ODUG - Web Services, Sep 2008
Four modules created__Intf.pas
Exposed methods for the web servicesIMyWebClass = class(Invokable)
__Impl.pasDelphi implementation of web servicesTMyWebClass = class(TInvokableClass,
IMyWebClass)Here’s the meat!
Data module – web service work horseMain Form – standard application
10ODUG - Web Services, Sep 2008
Add interface and implementationIntf and Impl units
Build/Run once to register COM objectRun Web App Debugger, start serverVerify new web service available in browserView WSDL automatically created for us
What’s a WSDL?Web Service Description LanguageXML document describing the web service
We’ve Created a Web Service!
11ODUG - Web Services, Sep 2008
Questions?
Now on to the Client…
12ODUG - Web Services, Sep 2008
New standard VCL applicationFile > New
Other > Web Services > WSDL ImporterURL of web service’s WSDLNew unit created
Full Interface to web service methods!
13ODUG - Web Services, Sep 2008
Call a method—see the answer—SUCCESS!Web App Debugger
View the logSee the XML packets
Get/Response – general web page requestsPOST – web service method calls
14ODUG - Web Services, Sep 2008
Web Apps –vs- Windows AppsNo formStatelessMulti-user
AcronymnsHTTP – HyperText Transfer ProtocolXML – eXtended Markup LanguageSOAP – Simple Object Access ProtocolRIO – Remote Invokable ObjectWSDL – Web Service Description LanguageUDDI – Universal Description, Discovery, and
Integration
15ODUG - Web Services, Sep 2008
Web ServiceAdd(a, b: Double): Double;Subtract(a, b: Double): Double;
ClientTwo edit fields, two buttons, display answer
16ODUG - Web Services, Sep 2008
Database queriesArraysTRemotable class
17ODUG - Web Services, Sep 2008
Packet SizeServer speedBandwidth bottleneck
Trapping XMLLogging/modifying XML on-the-fly
Use HTTPRIO from WebServicesUse TXMLDocument from Internet
Tutorial Referencehttp://exposureroom.com/members/skumar.aspx/tutorials/post/1
18ODUG - Web Services, Sep 2008
eCommerceSample packetsXML Notepad
GoogleeBayAmazonFedExCDDBMapPointMore!
19ODUG - Web Services, Sep 2008
20ODUG - Web Services, Sep 2008