slide1 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
E178 Web Service Development With PowerBuilder 9.0 PowerPoint Presentation
Download Presentation
E178 Web Service Development With PowerBuilder 9.0

Loading in 2 Seconds...

play fullscreen
1 / 76

E178 Web Service Development With PowerBuilder 9.0 - PowerPoint PPT Presentation


  • 302 Views
  • Uploaded on

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

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'E178 Web Service Development With PowerBuilder 9.0' - sage


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
slide1

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
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
web service development with pb 9 01
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 ?
web service quick view what is web service
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
web service quick view where to find a service
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
web service quick view how to describe a service
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)
web service quick view communicate to a service
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.
web service quick view how to publish a service

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

web service quick view how to access a service

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 ?
web service development with pb 9 0 what s next
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
deploy pb nvo as web service create deploy pb nvo
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
deploy pb nvo as web service wizard for nvo deployment in pb 9 0
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

deploy pb nvo as web service generate stub and skeleton
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

deploy pb nvo as web service create wsdl document services
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

deploy pb nvo as web service set endpoint and operations
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

deploy pb nvo as web service summary 1
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
deploy pb nvo as web service summary 2
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
web service development with pb 9 0 what s next1
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
access web service in powerscript standards used in pb 9 0
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
access web service in powerscript overview
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

access web service in powerscript components in pb 9 0
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
access web service in powerscript proxy wizard generator in pb 9 0
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.

access web service in powerscript proxy wizard generator in pb 9 07

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

access web service in powerscript how to use proxy in powerscript
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
access web service in powerscript how to use proxy cont
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”)

access web service in powerscript how to use proxy cont1
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”

access web service in powerscript error handling in powescript
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
access web service in powerscript example use the service
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

access web service in powerscript data type support and mapping
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)

web service development with pb 9 0 what s next2
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
accessing web services from jsp wizard for custom bean in pb 9 0
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.
accessing web services from jsp authoring jsp using custom tags
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.
accessing web services from jsp a simple example
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" %>

accessing web services from jsp authoring jsp using a custom tag
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 %>

); %>

accessing web services from jsp authoring jsp declare the tag library
Accessing Web Services from JSPAuthoring JSP – Declare the Tag Library

<%@ taglib uri="WEB-INF/tlds/examples.publish.Exchange.tld" prefix="exchange" %>

  • Declare the custom tag library to the JSP.
    • Makes all the tags in the library available to the page
    • The “exchange” prefix allows for easy reference to the tag library.
accessing web services from jsp authoring jsp declare arguments
Accessing Web Services from JSPAuthoring JSP – Declare Arguments

<%

String firstCountry = "usa";

String secondCountry = "japan";

Float exchangeRate;

%>

  • Declare input and output arguments and associate them with the operation to allow the custom bean to access them.
    • Allows data types other than strings to be used by the tag
accessing web services from jsp authoring jsp invoke custom tag
Accessing Web Services from JSPAuthoring JSP – Invoke custom tag

<exchange:getRate country1="<%= firstCountry %>"

country2="<%= secondCountry %>" />

  • Invoke the web service through the custom tag.

<%

exchangeRate = (Float) CurrencyExchangeService_getRate_returnValue;

out.println(“The exchange rate between ” + firstCountry +

“ and ” + secondCountry + “is: ” + exchangeRate); %>

  • Get the value of the exchangeRate variable from the custom tag and display it
    • exchangeRate is set when the tag is executed
accessing web services from jsp authoring jsp error handling
Accessing Web Services from JSPAuthoring JSP – Error Handling
  • The custom tags for web services will throw a JspTagException for non-recoverable error.
  • The JspTagException contains information about the root cause of the exception as well as where the error occurred in processing the custom tag.
  • Using PB 9.0 error handling facility this exception can be mapped to specific error page.
accessing web services from jsp deployment
Accessing Web Services from JSPDeployment
  • Deployment of custom bean for web services is same as deployment of any custom bean in PB 9.0
    • Custom tag libraries for web services must be specified on the tag libraries screen
accessing web services from a jsp a peek under the hood
Accessing Web Services from a JSP --- A peek under the hood

When the wizard creates a custom tag library code is generated to perform the invocation of the web service

  • Gets user values from the JSP page
  • Sets up the parameter list for the method call
  • Extracts return values from the method call and places them back into page variables
  • Uses the Universal Proxy to call the web service
accessing web services from a jsp universal proxy functionality
Accessing Web Services from a JSP --- Universal Proxy Functionality

The Universal Proxy hides the implementation of Web services processes from the client developer. It performs all of the tasks specifically related to invoking a Web Service.

  • Accepts Web service information
  • Serializes and deserializes data
  • Builds the SOAP request
  • Makes the internet connection and transmits the request
  • Processes the SOAP response
  • Provides the JSP with return and output data or fault information when the request fails.
accessing web services from a jsp universal proxy features
Accessing Web Services from a JSP --- Universal Proxy Features
  • Messaging Support
    • SOAP
  • Transport Protocol Support
    • Http
    • Https
  • WSDL Support
    • Reads WSDL file at runtime to gather information for requested service
accessing web services from a jsp universal proxy features cont
Accessing Web Services from a JSP --- Universal Proxy Features (cont.)
  • JAXP Compliant.
    • Supports JAXP-compliant parsers that support XML Namespaces
  • User-Defined Types
    • Extensible to handle user-defined types.
accessing web services from a jsp invoking the proxy directly
Accessing Web Services from a JSP Invoking the proxy directly

If you cannot use the automatically generated JSP tags the UniversalProxy may be accessed directly

  • Should not be needed very often
  • Proxy instantiation
    • SoapProxy proxy = new SoapProxy( “ImplFilename.wsdl” );
  • Set Service name
    • proxy.setServiceName( “SeviceElementNameAttribute” );
  • Web service invocation
    • Object returnObj =

proxy.invokeService( “webServiceName”,

Vector serviceParams );

    • serviceParams is a Vector containing all the arguments for the method
accessing web services from a jsp other universal proxy methods
Accessing Web Services from a JSP --- Other Universal Proxy methods

The Universal Proxy has some miscellaneous methods that may be useful to the JSP developer.

  • setWsdlFilename
    • Allows user to set or change the wsdl file to be read.
  • setPorts
    • Allows user to override the endpoints specified in the WSDL.
  • setUserEncodingPropsLocation
    • Allows the user to specify the location of the properties file that holds information about user-defined types.
accessing web services from a jsp other universal proxy methods cont
Accessing Web Services from a JSP --- Other Universal Proxy methods (cont.)
  • setCacerts
    • Allows the user to specify the location of the certificate keystore when sending requests over https.
  • setJAXPDocumentBuilderFactoryImpl
    • Allows the user to specify which JAXP-compliant parser should be used.
accessing web services from a jsp user defined types
Accessing Web Services from a JSP --- User-Defined Types

The data types understood by the Universal Proxy can be extended to include user-defined types. To do so the following are required:

  • Class for user-defined type
  • Serializer and deserializer classes
  • Serializer rule,
  • Known encoding style
  • Registration of user-defined type
accessing web services from a jsp syuproxy props
Accessing Web Services from a JSP --- syuproxy.props

The syuproxy.props file contains information necessary for the Universal Proxy to do its job.

  • Location of WSDL files.
  • Location of the user.encoding.props file
  • JAXP parser implementation
  • Location of keystore to be used for https

Note: This file is optional and all values mentioned above can be set in other ways. If used, syuproxy.props must be in the system classpath.

sybase developer network sdn
Sybase Developer Network (SDN)

Additional Resources for Developers/DBAs

  • Single point of access to developer software, services, and up-to-date technical information:
    • White papers and documentation
    • Collaboration with other developers and Sybase engineers
    • Code samples and beta programs
    • Technical recordings
    • Free software
    • Join today: www.sybase.com/developer or visit SDN at TechWave’s Technology Boardwalk