clite power

Upload: marco-barrientos

Post on 14-Apr-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/27/2019 Clite Power

    1/42

    PB 9 Web Service Client

  • 7/27/2019 Clite Power

    2/42

    66 - 22003 Sybase, Inc. and its subsidiaries. All rights reserved.

    John Strano

    PowerBuilder Evangelist

    [email protected]

  • 7/27/2019 Clite Power

    3/42

    66 - 32003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Module Objectives

    Give an overview on how Web Services client works in PowerBuilder

    9.0 Provide the information on how to generate proxies for the Web

    Services

    Provide the information on how to use Web Services in PowerScript

    Cover installation/configuration/troubleshooting information

  • 7/27/2019 Clite Power

    4/42

    66 - 42003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Skills Prerequisites

    Experience with PowerBuilder 8.0

    Basic knowledge of the standards of Web Services

    WSDL(Web Service Description Language)

    XML and XML schema

    SOAP (Simple Object Access Protocol)

    If you want to produce Web Service from PB component on EAServer,you need to get familiar to EAServer 4.2 Web Service Package, pleaserefer to EAServer documents.

  • 7/27/2019 Clite Power

    5/42

    66 - 52003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Definitions -- WSDL

    WSDL -- Web Services Description Language

    Defined the rule of describing the underneath components in XML format. Must include:

    Service name and ports(endpoints)

    Binding information -- transport protocol (soap, http get, http post, or others)

    PortType -- define all operations in this service Messages -- data exchanged between client and server side such as

    parameters of functions, return value.

    Namespaces and Schema -- refer to well known data types or define newdata types such as structure, array.

  • 7/27/2019 Clite Power

    6/42

    66 - 62003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Definitions -- XML Schema

    XML Schema The rule of defining new data types and complex types such as array,

    structure, enumeration, and composed data types.

    There are several standard schemas, which have already defined the wellknown data types such as string, integer, etc.

    W3C schema 1999 W3C schema 2000/10

    W3C schema 2001

    SOAP schema

  • 7/27/2019 Clite Power

    7/4266 - 72003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Definitions -- SOAP

    SOAP -- Simple Object Access Protocol A lightweight XML-based protocol

    All messages exchanged between SOAP client and server are in XMLformat. And SOAP can use HTTP, FTP, SMTP, and other transportprotocols.

    It is platform and language independent Use Envelop/Header/Body to represent the messages.

  • 7/27/2019 Clite Power

    8/4266 - 8

    2003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Definitions -- Web Service Proxy

    Web Service Proxy In PowerBuilder 9

    A PB object to represent the remote Web Service It includes:

    All functions exposed by Web Services and their signature

    Complex data types used by the Web Services

    Namespaces and schemas used by the Web Services Default Endpoint

  • 7/27/2019 Clite Power

    9/4266 - 9

    2003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Module Map

    Introduction to PB Web Service Client

    How Web Services work PB Web Service client internals

    Standards used in PB Web Service Client

    Strong/Weak Points of PB Web Service Client

    Create Web Services proxy in PowerBuilder 9 Using Web Services in PowerScript

    Where to get help

  • 7/27/2019 Clite Power

    10/4266 - 10

    2003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Introduction to Web Service Client

    How Web Services work

    5. Create WS proxy

    from WSDL

    6. Use proxy to

    invoke Web Services

    Web service

    Proxy

    1. Create Server Side

    components

    2. Wrap to WS

    3. Generate WSDL4. Publish

    Web service

    Stub

    Invoke

    Data

    PowerScript NVO or Other

    components

    12

    3WSDL

    Files

    Client Side Server Side

    5

    6

  • 7/27/2019 Clite Power

    11/4266 - 11

    2003 Sybase, Inc. and its subsidiaries. All rights reserved.

    PB Web Service Client Internals

    Web Service Wizard

    Collect information such as thelocation of WSDL, service, ports,etc.

    Proxy Generator

    Create WS proxy based on theinformation above

    Universal SOAP Client

    Instantiate WS proxy, communicate

    to WS server Error Handling

    Capture exception/error

    Web Service Wizard

    Proxy Generator

    Universal Soap Client

    Exception Processor

    Generator

    Data Store

    PB Proxy

    Info

    Proxy

    Instance

    WSDL file

    PowerScript

    PB 9

  • 7/27/2019 Clite Power

    12/4266 - 12

    2003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Sample -- How to invoke WS

    SoapConnection conn // Define SoapConnection (Universal Soap Client)demo_ieuroport proxy_obj // Define proxy

    long rVal

    real amount

    conn = create SoapConnection //Instantiated soap client

    rVal = Conn.CreateInstance(proxy_obj, " demo_ieuroport") // // Create proxy object

    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

  • 7/27/2019 Clite Power

    13/42

    66 - 132003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Standards Used In PB Web Service Client

    Standards supported in PB 9

    XML Schema 1.1 WSDL 1.1

    SOAP 1.1 over HTTP

    Standards not supported in PB9

    UDDI

  • 7/27/2019 Clite Power

    14/42

    66 - 142003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Good/Weak points of PB WS Client

    Strong Points

    Generic Conform to W3C standards

    Can make use of any Web services no matter the services are created in

    PowerBuilder, .Net, Java, or other third party tools

    Easy to use There is a Wizard to help user generate proxy

    Good error handling system

    Weak Points

    Only support SOAP messaging; dont support HTTP Get/Post Dont support UDDI

    Not support for all XML data types

  • 7/27/2019 Clite Power

    15/42

    66 - 152003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Module Map

    Introduction to PB Web Service Client

    Create Web Services proxy in PowerBuilder 9 Using Web Service Proxy Wizard to collect information

    Using Web Service Proxy Wizard

    Data types supported

    Data types not supported

    Schemas supported

    Troubleshooting

    Using Proxy Generator to create Web Service proxy

    Using Web Services in PowerScript

    Where to get help

  • 7/27/2019 Clite Power

    16/42

    66 - 162003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Using Web Service Proxy Wizard

    Purpose of Web Service Proxy Wizard

    Collects information such as location of WSDL file, service, port(s), proxyname, and target library

    Create a proxy generator object in PowerBuilder library

    To Start The Wizard Select the Web Service Proxy Wizard icon from Project page of the New

    dialog box

    Information collected includes: The location of the WSDL file, it could be a local file or an URL.

    Service -- Only one service can be selected in this wizard.

    Port(s) -- One service may be exposed to several ports. Only SOAP portscan be used in PB.

    Proxy name -- Give a prefix, which will be added to the default proxyname to avoid the name conflict. Default proxy name is the port name.

    Library name -- Where to deploy the proxy.

    Project name -- A project to store all these information.

  • 7/27/2019 Clite Power

    17/42

    66 - 172003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Using Web Service Proxy Wizard

    Demo

  • 7/27/2019 Clite Power

    18/42

    66 - 182003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Primitive Data Types Supported

    XML Primitive Data Types Supported and PB Types Mapping

    XML Type PB Typeboolean

    byte

    unsignedByte

    shortunsignedShort

    int

    unsignedInt

    longunsignedLong

    integer

    boolean

    int (-128~127)

    uint (0~255)

    intuint

    long

    ulong

    longlonglonglong (*)

    longlong

    XML Type PB Typedouble

    string

    date

    timedatetime

    duration

    base64Binary

    hexBinarybase64

    double

    string

    date

    timedatetime

    double

    blob

    blobblob

    decimaldecimal

    float real

    * 1~ 264-1

  • 7/27/2019 Clite Power

    19/42

    66 - 192003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Enumeration

  • 7/27/2019 Clite Power

    20/42

    66 - 202003 Sybase, Inc. and its subsidiaries. All rights reserved.

    XML Complex Type(structure)

    $PBExportHeader$s__soapstruct.srs

    $PBExportComments$Proxy imported fromWeb Service via Web Service Proxygenerator.

    global type s__SOAPStruct from structure

    string varString

    long varInt

    real varFloat

    end type

    Composed Data Types Supported (cont)

    XML Composed Data Types Supported and Mapping

    XML Type PB Type2. complex type (structure)) structure

    Examples

  • 7/27/2019 Clite Power

    21/42

    66 - 212003 Sybase, Inc. and its subsidiaries. All rights reserved.

    1-dimension array

    int []

    Composed Data Types Supported (cont)

    XML Composed Data Types Supported and Mapping

    XML Type PB Typearray3. 1-dim unbounded array

    Examples

  • 7/27/2019 Clite Power

    22/42

    66 - 222003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Data Types Not Supported

    PB 9 doesnt support:

    Any other primitive data types except for those included in previouspages

    Multi-dimension array

  • 7/27/2019 Clite Power

    23/42

    66 - 232003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Schemes Supported

    PB 9 supports following schemas:

    W3C XML schema 1999 W3C XML schema 2000/10

    W3C XML schema 2001

    SOAP schema

    PB9 doesnt support: Private schemas

    Messages use different schema from the complex data type definition

  • 7/27/2019 Clite Power

    24/42

    66 - 242003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Troubleshooting & Output

    Error Messages

    The Wizards will give error message when fail to parse the WSDL file

    Output If everything went well, the proxy generator project will be create by Wizard

  • 7/27/2019 Clite Power

    25/42

    66 - 252003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Module Map

    Introduction to PB Web Service Client

    Create Web Services proxy in PowerBuilder 9 Using Web Service Proxy Wizard to collect information

    Using Proxy Generator to create Web Service proxy

    Using Proxy Generator

    Change properties

    Change Service/Ports

    Generate proxy

    Using Web Services in PowerScript

    Where to get help

  • 7/27/2019 Clite Power

    26/42

    66 - 262003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Using Proxy Generator

    Purpose of Web Service Proxy Generator

    Advanced user can modify any information in Generator project, whichwas collected by Wizard

    Advanced user can create a Generator project form scratch.

    Create Web Service proxy and structure if needed

    Proxy Generator Mini-Toolbar

    Save the Project

    Close project

    Display & change service/ports2

    Change properties1

    Generate proxy3

  • 7/27/2019 Clite Power

    27/42

    66 - 272003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Change Properties

    Change properties -- General

    Deployment PBL --

    Where to put your proxyin when generate

    If the same proxy exists,

    do you want to clear theold one?

    Need to be confirmedexplicit?

  • 7/27/2019 Clite Power

    28/42

    66 - 282003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Change Properties (cont)

    Change properties -- Web Service

    WSDL Location -- Where

    is the WSDL file. Couldbe a local file or URL.

  • 7/27/2019 Clite Power

    29/42

    66 - 292003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Change Service/Ports

    Display & change service/ports

  • 7/27/2019 Clite Power

    30/42

    66 - 302003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Generate Proxy

    Generate proxy

  • 7/27/2019 Clite Power

    31/42

    66 - 312003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Module Map

    Introduction to PB Web Service Client

    Create Web Services proxy in PowerBuilder 9 Using Web Services in PowerScript

    Universal SOAP Client in PB 9

    SoapConnection Class

    SoapException Class

    Using SOAP Client & WS Proxy Sample code

    Troubleshooting

    Where to get help

  • 7/27/2019 Clite Power

    32/42

    66 - 322003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Universal SOAP Client

    Soap Client

    Packaged into PBSoapClient90.pbd & PBSoapClient90.Dll PBSoapClient90.Dll MUST be deployed with PB application

    New Classes in PB 9 to support SOAP Messaging

    SoapConnection class Used to instantiated the proxy object and populated SOAP options

    SoapException class Used to capture runtime errors/exceptions when calling Web Services

  • 7/27/2019 Clite Power

    33/42

    66 - 332003 Sybase, Inc. and its subsidiaries. All rights reserved.

    SoapConnection Class

    Functions in SoapConnection class

    CreateInstance --Instantiate WS proxy SetOptions -- Set options such as log file, userID, password

    CreateInstance CreateInstance(proxyObj, ProxyType)

    Create a proxy object using default endpoint

    CreateInstance(proxyObj, ProxyType, endpoint) Create a proxy object using specified endpoint

    SetOptions SetOptions(optionString)

    Format of optionString is Name/value pairs. For example: SoapLog=~C:\kt.log~, userID=~sa, Password=~sybase~

    SoapLog=C:\kt.log, userID=sa, Password=sybase

  • 7/27/2019 Clite Power

    34/42

    66 - 342003 Sybase, Inc. and its subsidiaries. All rights reserved.

    SoapException Class

    SoapException Class

    SoapException inherited from PowerBuilder RuntimeError object Errors that occur in the execution of a method of Web service are

    converted to SoapException objects and thrown to the calling script

    In PowerScript Use try-catch block to capture the exceptions

    Unhandled exception will be propagate to PB and cause SystemErrorevent to be executed

  • 7/27/2019 Clite Power

    35/42

    66 - 352003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Module Map

    Introduction to PB Web Service Client

    Create Web Services proxy in PowerBuilder 9 Using Web Services in PowerScript

    Universal SOAP Client in PB 9 SoapConnection Class

    SoapException Class

    Using SOAP Client & WS Proxy

    Sample code

    Troubleshooting

    Where to get help

  • 7/27/2019 Clite Power

    36/42

    66 - 362003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Using SOAP Client & WS Proxy

    Procedure

    Include PBSoapClient90.pbd to your PB target Create an instance of SoapConnection

    Set options for the Connection

    Create an instance of WS proxy using SoapConnection

    Call the function of the proxy to invoke Web Service

  • 7/27/2019 Clite Power

    37/42

    66 - 372003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Sample

    SoapConnection conn // Define SoapConnectiondemo_ieuroport proxy_obj // Define proxy

    long rVal

    real amount

    conn = create SoapConnection //Instantiated soap connection

    conn.SetOptions(SoapLog=c:\kt.log, userID=sa,Password=sybase) // Set optionsrVal = Conn.CreateInstance(proxy_obj, " demo_ieuroport") // // Create proxy object

    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

  • 7/27/2019 Clite Power

    38/42

    66 - 382003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Module Map

    Introduction to PB Web Service Client

    Create Web Services proxy in PowerBuilder 9 Using Web Services in PowerScript

    Universal SOAP Client in PB 9 SoapConnection Class

    SoapException Class

    Using SOAP Client & WS Proxy Sample code

    Troubleshooting

    Where to get help

  • 7/27/2019 Clite Power

    39/42

    66 - 392003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Troubleshooting

    Use SetOptions to set log file, which will capture the raw SOAP data

    exchange between client and server

  • 7/27/2019 Clite Power

    40/42

    66 - 402003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Module Map

    Introduction to PB Web Service Client

    Create Web Services proxy in PowerBuilder 9 Using Web Services in PowerScript

    Where to get help

    f

  • 7/27/2019 Clite Power

    41/42

    66 - 412003 Sybase, Inc. and its subsidiaries. All rights reserved.

    Where to go for help

    For Wizard, Generator, Universal Soap Client

    PB 9 manual and online help PB 9 Functional Specification

    For Standards XML Schema 1.1

    http://www.w3.org/XML/Schema

    WSDL 1.1 WSDL --- http://www.w3.org/TR/2003/WD-wsdl12-20030124/

    Binding --- http://www.w3.org/TR/2003/WD-wsdl12-bindings-20030124/

    SOAP 1.1 http://www.w3.org/TR/2002/CR-soap12-part0-20021219/

    Q & A

  • 7/27/2019 Clite Power

    42/42

    Q & A

    John Strano

    PowerBuilder Evangelist

    [email protected]