880 likes | 1.33k Views
4GL Clients Accessing Industry Web Service. Agenda. OpenEdge Web Services 4GL Client Overview WSDL Analyzer Calling a Web Service from the 4GL Handling Data to/from Progress & Web Services New & Enhanced Language Constructs Accessing SOAP Headers Error Handling.
E N D
Agenda • OpenEdge Web Services 4GL Client Overview • WSDL • Analyzer • Calling a Web Service from the 4GL • Handling Data to/from Progress & Web Services • New & Enhanced Language Constructs • Accessing SOAP Headers • Error Handling
Web Services 4GL Client Overview POST(SOAP) SOAP Processor HTTP Client Response(SOAP) WSDL Web Service Access from the 4GL • Calling a Web service from the Progress 4GL • Similar to calling an AppServer procedure A Web Service A Web Services-enabled application OpenEdge 4GL Client
Three Examples • Internet Temperature Sample • Internet StockQuote Sample • Internal .NET BlackBox CreditCheck
Temperature Sample A Web Service getTemp Bedford, MA 01730 Orlando, FL 32801
StockQuotes Sample A Web Service getQuote
CheckCreditWindow.w A Web Service • ServiceCreditCheckSoap • CheckCredit • getMaxCredit
Lab Setup and Sample Demo nstration • Using the “Black Box Web Service Install.doc” supplied as prerequisite deploy the web service files • Complete “Lab Setup and Sample Demonstration” section
Agenda • OpenEdge Web Services 4GL Client Overview • WSDL • Analyzer • Calling a Web Service from the 4GL • Handling Data to/from Progress & Web Services • New & Enhanced Language Constructs • Accessing SOAP Headers • Error Handling
WSDL Web Service Description Language W3C note – defacto standard http://www.w3.org/TR/WSDL.html • XML Document describing the Web Service • Service interface What does it do? • Service implementation How do I invoke it? • Service location Where is it? • A contract between the client and server
WSDL Web Service Description Language • Specifies interface • Business methods that can be invoked (“operations”) • Message structure for each method • Data fields, types • Bindings for the operations • SOAP over HTTP • Identifies network address of Web Service
Web Service Development Roles • Web Service Developer • Develops, publishes, deploys the Web Service & WSDL • Web Service Client Developer • Toolkits used to generate client code/proxies • WSDL • Abstract Definitions • Platform and language independent • Concrete Definitions • Maps operations to actual protocols and service locations
WSDL Structure WSDL Definitions • WSDL Types • Data type definitions (XML Schema) • WSDL Messages • Combinations of data fields (“parts”) • Message Name unique to identify message • WSDL Ports • Each Port Element specifies a binding & location • WSDL Bindings • Bindings specified for operations • E.g. SOAP; HTTP POST, GET • Namespace, encodings specified for SOAP bodies, relative locations specified • WSDL Services • Associates a URL with each port / binding WSDL Types WSDL Messages WSDL Parts WSDL Ports WSDL Operations WSDL Bindings Operation Bindings WSDL Services Addresses for Ports
WSDL Sections Types (Object IDs, TEMP-TABLEs) Messages (4GL procedure request/response) Abstract PortTypes Operations Operations Bindings Concrete Services Ports
WSDL PortTypes Web Service “Procedure Object” • Encapsulates operations in a Web Service • Mapped to portType element of WSDL • Used to invoke operations • RUN statement • FUNCTION call
Agenda • OpenEdge Web Services 4GL Client Overview • WSDL • Analyzer • Calling a Web Service from the 4GL • Handling Data to/from Progress & Web Services • New & Enhanced Language Constructs • Accessing SOAP Headers • Error Handling
WSDL Analyzer • Processes the WSDL • Generates documentation for 4GL developer • How to connect • How to create • How to invoke • Depending on the Web service you will either use a RUN statement or a FUNCTION call
WSDL Analyzer Utility to analyze and document WSDL • bprowsdldoc
WSDL Analyzer Output Service Data Types PortType PortType PortType Service DataTypes PortType PortType PortType (1) (2) 1 Main hypertext link (from service list to actual entry) 2 Secondary hypertext link (cross reference)
WSDL Analyzer Output • Temperature Sample • Stock Quotes • Lab – CheckCredit
WSDL Analyzer - Temperature Port Types - 1 of 3
WSDL Analyzer - Temperature Port Types – 2 of 3
WSDL Analyzer - Temperature Port Types – 3 of 3
WSDL Analyzer Output • Temperature Sample • Stock Quotes • Lab – CheckCredit
WSDL Analyzer – Stock Quotes Port Types – 1 of 3
WSDL Analyzer – Stock Quotes Port Types – 2 of 3
WSDL Analyzer – Stock Quotes Port Types – 3 of 3
WSDL Analyzer – Stock Quotes Parameters – GetStockQuotes
WSDL Analyzer – Stock Quotes Parameters – GetStockQuotesResponse 1 of 2
WSDL Analyzer – Stock Quotes Parameters – GetStockQuotesResponse 2 of 2
WSDL Analyzer Output • Temperature Sample • Stock Quotes • Lab – CheckCredit
Using the WSDL Analyzer Lab • Complete “Using the WSDL Analyzer” section of the lab
Agenda • OpenEdge Web Services 4GL Client Overview • WSDL • Analyzer • Calling a Web Service from the 4GL • Handling Data to/from Progress & Web Services • New & Enhanced Language Constructs • Accessing SOAP Headers • Error Handling
Calling a Web Service from the 4GL Similar to Accessing an AppServer AppServer Web Service • Create server handle • Connect to AppServer • Run procedures • Disconnect • Delete server handle • Create server handle • Bind to Web Service • Invoke WS operations • Disconnect • Delete server handle
Calling a Web Service from the 4GL Similar to Accessing an AppServer AppServer Web Service • Create server handle • Connect to AppServer • Run procedures • Persistent Procedure • IPs, UDFs • Delete handle • Disconnect • Delete server handle • Create server handle • Bind to Web Service • Invoke WS operations • Identify portType • Run / Call Service • Delete handle • Disconnect • Delete server handle
Calling a Web Service from the 4GL • Create server handle • Bind to Web Service • Invoke operations on the Web Service • Identify portType • Run / Call Service • Delete handle • Disconnect • Delete server handle
Enhanced 4GL Constructs • CONNECT method • “Binds” the Web Service to the handle • RUNON statement SET . . . . • Creates a “proc object” for a Web Service operation • Invoke the PortType and get a handle to “proc object” • RUN IN statement • Call Web Service operation • FUNCTIONstatement • Maps a UDF prototype to a Web Service operation that specifies a <return> parameter element
Invoking a Web Service Operation Web Service “Procedure Object” • RUN • Used for operations that do not have a return parameter • Synchronous or Asynchronous • FUNCTION • Used for operations that have a return parameter • Synchronous only
Calling a Web Service from the 4GL DEFINE VARIABLE hWebService AS HANDLE. CREATE SERVER hWebService. hWebService:CONNECT(connection_parameters). RUN portTypeName SET hPortType ON SERVER hWebService. RUN operationName IN hPortType NO-ERROR. FUNCTION operationName RETURNS dataType IN hPortType. DELETE PROCEDURE hPortType. hWebService:DISCONNECT(). DELETE OBJECT hWebService. 1 2 3 4 5
Additional Parameters on CONNECT() • Character String, space separated list -WSDL -WSDLUserId -WSDLPassword -Service -ServiceNamespace -Port -Binding -BindingNamespace -SOAPEndpoint -SOAPEndpointUserId -SOAPEndpointPassword -TargetNamespace -MaxConnections -pf
Calling a Web Service from the 4GL Demo • Temperature Sample • Stock Quotes Sample
From the WDSL Analyzer • DEFINE VARIABLE hWebService AS HANDLE. • DEFINE VARIABLE hTemperaturePortType AS HANDLE. • CREATE SERVER hWebService. • hWebService:CONNECT("-WSDL • 'http://www.xmethods.net/sd/2001/TemperatureService.wsdl' • -Service TemperatureService • -Port TemperaturePort"). • RUN TemperaturePortType SET hTemperaturePortType ON hWebService. 1 2 3a • Connect Method Parameters • Example
From the WDSL Analyzer • DEFINE VARIABLE zipcode AS CHARACTER. • DEFINE VARIABLE return AS CHARACTER. • RUN getTemp IN hTemperaturePortType • (INPUT zipcode, OUTPUT return). 3b • Operation (internal procedure) detail • getTemp • Example
Temperature Sample Call – RPC encoded • Create Server Object DEFINE VARIABLE hWebService AS HANDLE. … CREATE SERVER hWebService. 1 • “Bind” to the Web Service 2 hWebService:CONNECT("-WSDL 'http://www.xmethods.net/sd/2001/TemperatureService.wsdl' "). IF NOT hWebService:CONNECTED() THEN MESSAGE "SERVER NOT CONNECTED" VIEW-AS ALERT-BOX.
Temperature Sample Call – RPC Encoded • Sets the handle to the port type in the WSDL where the Web service operation is defined and waits for the user to invoke the request • DEFINE VARIABLE hPortType AS HANDLE. • . . . • RUN TemperaturePortType SET hPortType ON SERVER hWebService • NO-ERROR. • IF ERROR-STATUS:ERROR THEN • MESSAGE "Failed to create hPortType" VIEW-AS ALERT-BOX. • WAIT-FOR CLOSE OF CURRENT-WINDOW. 3a
Temperature Sample Call - RPC Encoded • Invokes the Web service getTemp operation by making a procedure call • DEFINE VARIABLE cTemp AS CHARACTER. • . . . • ON CHOOSE OF bgetTemp • DO: • cZipCode = fillin-1:SCREEN-VALUE. • RUN getTemp IN hPortType (INPUT cZipCode, OUTPUT cTemp) NO-ERROR. • . . . 3b
Temperature Sample Call - RPC Encoded • If there are no errors assign the screen-value for cTemp • IF ERROR-STATUS:ERROR THEN • DO: • /* Code you will see during error handling */ • END. • ELSE • fillin-2:SCREEN-VALUE = STRING(cTemp, "99").
Temperature Sample Call - RPC Encoded • Delete procedure handle 3 DELETE PROCEDURE hPortType. • “Disconnect” from Web Service 4 hWebService:DISCONNECT(). • Delete Server Handle 5 DELETE OBJECT hWS.