1 / 76

E178 Web Service Development With PowerBuilder 9.0

E178 Web Service Development With PowerBuilder 9.0. Jinyou Zhu Senior Software Engineer Sybase Inc. jyzhu@Sybase.com. Chris Rank Senior Software Engineer Sybase Inc. crank@Sybase.com. Web Service Development With PB 9.0. Section 1: Web Service Quick View

sage
Download Presentation

E178 Web Service Development With PowerBuilder 9.0

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. E178 Web Service Development With PowerBuilder 9.0 • Jinyou Zhu • Senior Software Engineer • Sybase Inc. • jyzhu@Sybase.com • Chris Rank • Senior Software Engineer • Sybase Inc. • crank@Sybase.com

  2. Web Service Development With PB 9.0 • Section 1: Web Service Quick View • Section 2: Deploy PB NVO as Web service • Section 3: Access Web service in PowerScript • Section 4: Access Web service in JSP • Demos

  3. Web Service Development With PB 9.0 Section 1: Web service quick view • What is Web service ? • Where to find a service ? • How to define/describe a service ? • How to communicate to a service ? • How to publish a service ? • How to access a service ?

  4. Web Service Quick View-- What is Web service? Web service is defined as use of Internet technologies to make distributed software components talk to each other. • Available over Internet or private intranet networks • Uses a standardized XML messaging system • Self-describing via a common XML grammar • Discoverable via a simple find mechanism • Not tied to any OS and languages • Separate Web service description from implementation

  5. Web Service Quick View-- Where to find a service ? UDDI -- A central registry UDDI (Universal, Description, Discovery and Integration) is a place to store the information about your business, your services, and other technical information • White Page -- Business description and related information • Yellow Page -- Index of services • Green Page -- Technical documents about the services

  6. Web Service Quick View-- How to describe a service ? Web Service Description Language (WSDL) WSDL is an XML grammar for specifying a public interface for a Web service • Namespaces • Complex data types -- structures • Messages -- data between client and server • PortType -- Operations in the service • Binding information -- transport protocol • Service and ports (endpoints)

  7. Web Service Quick View-- Communicate to a service ? SOAP SOAP is an XML-based protocol for exchanging information between computers • XML-based messaging • Platform- and language-independent • Can be delivered via a variety of transport protocol such as HTTP, FTP, SMTP, and BEEP etc.

  8. WSDL file Invoke Return Server Side Step 1: Create functionality (component) Step 2: Create SOAP service wrapper Step 3: Create WSDL file Step 4: Deploy service Step 5: Publish service to UDDI Web Service Quick View-- How to publish a service ? Registry (UDDI) Client Server

  9. UDDI Site Searching WSDL file Server Invoke Client Return Client Side Step 1: Find service via UDDI Step 2: Retrieve WSDL file Step 3: Create SOAP client Step 4: Invoke service Web Service Quick View-- How to access a service ?

  10. Web Service Development with PB 9.0-- What’s Next ? • Section 1: Web Service Quick View • Section 2: Deploy PB NVO as Web service • Deploys PB NVO to EAServer • Generates stub and skeleton • Creates WSDL document and service • Sets endpoint and selects operations • Generates WSDL file

  11. Deploy PB NVO as Web Service-- Create & deploy PB NVO Create NVO • PowerBuilder 9.0 has complete facility to create object -- visual or non visual (NVO) Deploy NVO to EAServer • EAServer Component Wizard • Deployment

  12. Deploy PB NVO as Web Service-- Wizard for NVO deployment in PB 9.0 EAServer Component Wizard in PB 9.0 • Collects information such as library, component, EAServer, package, type of component, and transaction. • Creates a generator for deployment • Generator will deploy the NVO to EAServer Demo -- EAServer component wizard

  13. Deploy PB NVO as Web Service-- Deploy PB NVO to EAServer

  14. Deploy PB NVO as Web Service -- Generate stub and skeleton • Stub -- client side • Allow client to interact with server components as if they are local components • Skeleton -- server side • Allow EAServer to invoke your component methods Demo -- Generate Stub/Skeleton

  15. Deploy PB NVO as Web Service -- Create WSDL document & services • WSDL document works as a Web service container • It setups definition name and target name space • One WSDL document --> each WSDL file • You can create several services in one document • One service will wrap only one component. • Once service is set, more properties can be set to add functionality. Demo -- Create WSDL Document and services

  16. Deploy PB NVO as Web Service -- Set endpoint and operations • Endpoint -- where the web service will reside • includes protocol, port, host, WebApp Context, and URL Pattern. • Operations • Select operations in the component, which you want to expose as Web service Demo -- Set properties and generate WSDL file

  17. Deploy PB NVO as Web Service -- Summary (1) 6Steps to deploy PB NVO as Web service • Step 1: Deploy NVO to EAServer using wizard • Step 2: Generate and compile stub/skeleton • Step 3: Create empty WSDL document • Step 4: Create service in the document • Step 5: Add endpoint and operations, The WSDL file will be generated automatically. • Step 6: Copy the WSDL file to Web server

  18. Deploy PB NVO as Web Service -- Summary (2) Advantages • PowerBuilder is tightly integrated with EAServer • PowerBuilder has wizard to help users to deploy the NVO • It is very easy to use

  19. Web Service Development With PB 9.0 -- What’s Next ? • Section 1: Web Service Quick View • Section 2: Deploy PB NVO as Web service • Section 3: Access Web service in PowerScript • How to generate Web service proxy? • How to use Web service proxy? • Error handling in PB 9.0 • Data mapping in PB 9.0 • Examples

  20. Access Web service in PowerScript -- Standards used in PB 9.0 Messaging & Transport Protocol • SOAP 1.1 over HTTP/HTTPS Service Description • WSDL 1.1 Service Discovery (not support right now) • UUDI

  21. Access Web service in PowerScript-- Overview WSDL Files 3 Two things need to be done for client side • Generates Proxy -- Communicates to server • Uses proxy and error handling Web service Server PowerScript 1 Other components NVO 2 Invoke Web service Proxy Web service Stub Data

  22. Access Web service in PowerScript-- Components in PB 9.0 Generates proxy from WSDL file • Web service wizard and generator Uses proxy • SoapConnection object Error handling • SoapException object

  23. Access Web service in PowerScript -- Proxy wizard/generator in PB 9.0 Web service proxy wizard • Collects information such as location of WSDL file, service, port(s), proxy name, and target library • Create a proxy generator object in PowerBuilder library Proxy generator • User can set/change any property • Create proxy objects and structures and deploy them into specified PowerBuilder library Note: Proxy generation is port based.

  24. Access Web service in PowerScript -- Proxy wizard/generator in PB 9.0 Select the WSDL file to use

  25. Access Web service in PowerScript -- Proxy wizard/generator in PB 9.0 Select the service

  26. Access Web service in PowerScript -- Proxy wizard/generator in PB 9.0 Select the port(s)

  27. Access Web service in PowerScript -- Proxy wizard/generator in PB 9.0 Select the proxy name

  28. Access Web service in PowerScript -- Proxy wizard/generator in PB 9.0 Select the library to deploy

  29. Access Web service in PowerScript -- Proxy wizard/generator in PB 9.0 Review and create the Gentor

  30. 1. Mini toolbar 2. System Tree Access Web service in PowerScript -- Proxy wizard/generator in PB 9.0 Gentor project 3. Project Window Demo -- Use wizard/generator to create WS proxy

  31. Access Web service in PowerScript -- Proxy wizard/generator in PB 9.0 Proxy

  32. Access Web service in PowerScript -- How to use proxy in PowerScript SoapConection object • Used to instantiated the proxy object and populated SOAP options • Implemented in PBSoapClient90.pbd, so this .pbd file MUST be added to current target Functions in SoapConnection class • CreateInstance - Create a proxy instance • SetOptions - Set log file, user name, and password

  33. Access Web service in PowerScript -- How to use proxy (cont.) SoapConection object 1. CreateInstance • CreateInstance(proxyObj, ProxyType) -- Create a proxy object using default endpoint CreateInstance(obj, “Calculator”) • CreateInstance(proxyObj, ProxyType, endpoint) -- Create a proxy object using specified endpoint CreateInstance(obj, “Calculator”, “ http://sybase.com”)

  34. Access Web service in PowerScript -- How to use proxy (cont.) SoapConection object 2. SetOptions • SetOptions(optionString) -- Set options for the connection -- Options include log file, user ID, and password • Format of optionString -- Name/value pairs Example: “SoapLog=~”Logpath”, userID=~”username”, Password=~”password”

  35. Access Web service in PowerScript -- Error handling in PoweScript SoapException object • SoapException inherited from PowerBuilder RuntimError object • Errors that occur in the execution of a method of Web service are converted to SoapException objects and thrown to the calling script For PowerScript • Use try-catch block to capture the exception • Unhandled exception will be propagate to PB and cause SystemError event to be executed

  36. Access Web service in PowerScript -- Example: Use the service SoapConnection conn // Define SoapConnection demo_ieuroport proxy_obj // Define proxy long rVal real amount conn = create SoapConnection //Instantiated connection // Create proxy object rVal = Conn.CreateInstance(proxy_obj, " demo_ieuroport") try amount = proxy_obj.toeuro(100, “DEM”) // Invoke service // use the amount …. catch ( SoapException e ) messagebox (“Error”, “Cannot invoke WS”)// error handling end try destroy conn

  37. Access Web service in PowerScript -- Data type support and mapping XML Type PB Type XML Type PB Type boolean boolean decimal decimal byte int (-128~127) float real unsignedByte uint (0~255) double double short int string string unsignedShort uint date date int long time time unsignedInt ulong datetime datetime long longlong base64Binary blob unsignedLong longlong (*) hexBinary blob integer longlong base64 blob * range (0 ~2exp63 -1)

  38. Web Service Development With PB 9.0 -- What’s Next ? • Section 1: A Quick Look at Web Services • Section 2: Deploy a PB NVO as a Web service • Section 3: Accessing Web services from PowerScript • Section 4: Accessing Web Services from a JSP • Wizard for custom tag generation • Using the custom tag • Taglib directive + examples • Input/output parameters + examples • Error handling • Deployment

  39. Accessing Web Services from JSPWizard for Custom Bean in PB 9.0 • Wizard for Custom Beans • Collects information such as location of WSDL file, service, and port (s). • Provides for user-specified overrides for custom bean name, Java class name, Java package name, TLD name, Jar name, output variables and selection of operations within a service. • Provides as output a TLD file, Java source to process custom tag and compiled Java class files of source that can be deployed to a JSP container or used as standalone Java classes.

  40. Custom Tags Wizard for Web Services-- Select the WSDL file to use

  41. Custom Tags Wizard for Web Services-- Select the Services to include

  42. Custom Tags Wizard for Web Services-- Select the Operations to include

  43. Custom Tags Wizard for Web Services-- Modify parameter information

  44. Custom Tags Wizard for Web Services-- Select the ports for each Operation

  45. Custom Tags Wizard for Web Services-- Set a destination for the tag library

  46. Custom Tags Wizard for Web Services-- Generate the custom tag library

  47. Accessing Web Services from JSPAuthoring JSP – Using custom tags • Choose custom bean that represents web service to drag and drop on JSP from system tree. • Add Taglib directives. • Specify input and output arguments. All arguments must be represented as objects as they are stored in the pageContext of the JSP container. • Invoke custom tag. • Handle errors.

  48. Accessing Web Services from JSPAuthoring JSP -- System Tree

  49. Accessing Web Services from JSPA simple example Purpose is to define to JSP container custom tags that are to be used in this page. <%@ taglib uri="WEB-INF/tlds/examples.publish.Exchange.tld" prefix="exchange" %>

  50. Accessing Web Services from JSPAuthoring JSP – Using a custom tag <%@ taglib uri="WEB-INF/tlds/examples.publish.Exchange.tld" prefix="exchange" %> … <% String firstCountry = “usa”; String secondCountry = “japan”; Float exchangeRate; %> … <exchange:getRate country1="<%= firstCountry %>" country2="<%= secondCountry %>" /> … <% exchangeRate = (Float) CurrencyExchangeService_getRate_returnValue; out.println(“The exchange rate between ” + firstCountry + “ and ” + secondCountry + “is: ” + exchangeRate %> ); %>

More Related