Title: Title: Arial 28pt.
1PWB 519 Development of Web Service in PB 10
Jin-You Zhu Sr. Software Engineer Jyzhu_at_sybase.com
August 15-19, 2004
2The Enterprise. Unwired.
3The Enterprise. Unwired.
Industry and Cross Platform Solutions
Unwire People
Unwire Information
Manage Information
- Adaptive Server Enterprise
- Adaptive Server Anywhere
- Sybase IQ
- Dynamic Archive
- Dynamic ODS
- Replication Server
- OpenSwitch
- Mirror Activator
- PowerDesigner
- Connectivity Options
- EAServer
- Industry Warehouse Studio
- Unwired Accelerator
- Unwired Orchestrator
- Unwired Toolkit
- Enterprise Portal
- Real Time Data Services
- SQL Anywhere Studio
- M-Business Anywhere
- Pylon Family (Mobile Email)
- Mobile Sales
- XcelleNet Frontline Solutions
- PocketBuilder
- PowerBuilder Family
- AvantGo
Sybase Workspace
4-- Outline
Development of Web Service in PB 10
- What is Web Services
- How to Create Web Services in PB10
- How to Register Web Services in EAServer 5.x
- How to Find Web Services in PB10
- How to Write PB Web Services Client in PB10
- How to Write JSP Web Services Client in PB10
- Demo
- QA
5What is Web Services?
- 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 -- HTTP - Uses a standardized XML messaging system -- SOAP
- Self-describing via a common XML grammar -- WSDL
- Discoverable via a simple find mechanism -- UDDI
- Not tied to any OS and languages
- Separate Web service description from
implementation
63 Key Components of Web Services
- WSDL
- WSDL stands for Web Services Description
Language. It is an XML format for describing
network services as a set of endpoints operating
on messages containing either document-oriented
or procedure-oriented information. - http//www.w3.org/TR/wsdl
- SOAP
- SOAP stands for Simple Object Access Protocol. It
is a lightweight protocol for exchange of
information in a decentralized, distributed
environment. - http//www.w3.org/TR/soap12
- UDDI
- UDDI stands for Universal Description, Discovery
and Integration, it enables businesses to
quickly, easily, and dynamically find and
transact with one another. - http//www.uddi.org
7WSDL
- Types
- a container for data type definitions using some
type system (such as XSD, schema). - Message
- an abstract, typed definition of the data being
communicated. - Port Type
- an abstract set of operations supported by one or
more endpoints. - Binding
- a concrete protocol and data format specification
for a particular port type. - Service
- a collection of related endpoints.
- Port a single endpoint defined as a combination
of a binding and a network address.
8WSDL PortType Binding
- ltportType name"StockQuotesSoap"gt
- ltoperation name"GetStockQuotes"gt
- ltinput name"GetQuotes"
message"s0GetQuotesSoapIn" /gt - ltoutput name"GetQuotes"
message"s0GetQuotesSoapOut" /gt - lt/operationgt
- lt/portTypegt
- ltbinding name"StockQuotesSoap"
type"s0StockQuotesSoap"gt - ltsoapbinding transport"http//schemas.xmlso
ap.org/soap/http" style"document" /gt - ltoperation name"GetStockQuotes"gt
- ltsoapoperation soapAction"http//sw
anandmokashi.com/GetQuotes" style"document" /gt - ltinput name"GetQuotes"gt
- ltsoapbody use"literal" /gt
- lt/inputgt
- ltoutput name"GetQuotes"gt
- ltsoapbody use"literal" /gt
- lt/outputgt
- lt/operationgt
- lt/bindinggt
9WSDL -- Message
- ltmessage name"GetQuotesSoapIn"gt
- ltpart name"parameters" element"s0GetQuot
es" /gt - lt/messagegt
- ltmessage name"GetQuotesSoapOut"gt
- ltpart name"parameters" element"s0GetQuot
esResponse" /gt - lt/messagegt
- .
10WSDL -- Types
- lttypesgt
- ltsschema elementFormDefault"qualified"
targetNamespace"http//swanandmokashi.com"gt - ltselement name"GetQuotes"gt
- ltscomplexTypegt
- ltssequencegt
- ltselement
minOccurs"0" maxOccurs"1" name"QuoteTicker"
type"sstring" /gt - lt/ssequencegt
- lt/scomplexTypegt
- lt/selementgt
- ltselement name"GetQuotesResponse"gt
- ltscomplexTypegt
- ltssequencegt
- ltselement
minOccurs"0" maxOccurs"1" name"GetQuotesResult"
typestring" /gt - lt/ssequencegt
- lt/scomplexTypegt
- lt/selementgt
- lt/sschemagt
- lt/typesgt
11WSDL Services Ports
- ltservice name"StockQuotes"gt
- ltport name"StockQuotesSoap"
binding"s0StockQuotesSoap"gt - ltsoapaddress location"http//www.swanandmo
kashi.com/HomePage/WebServices/StockQuotes.asmx"
/gt - lt/portgt
- lt/servicegt
12SOAP
- 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.
13SOAP Request Message
- ltSOAP-ENVEnvelope xmlnsSOAP-ENV"http//schemas.
xmlsoap.org/soap/envelope/" xmlnsSOAP-ENC"http/
/schemas.xmlsoap.org/soap/encoding/"
xmlnsxsi"http//www.w3.org/2001/XMLSchema-instan
ce" xmlnsxsd"http//www.w3.org/2001/XMLSchema"gt - ltSOAP-ENVBodygt
- ltmGetQuotes xmlnsm"http//swanandmokashi.com"
gt - ltmQuoteTickergtSYlt/mQuoteTickergt
- lt/mGetQuotesgt
- lt/SOAP-ENVBodygt
- lt/SOAP-ENVEnvelopegt
14SOAP Response Message
- HTTP/1.1 200 OKContent-Type text/xml
charset"utf-8"Content-Length
nnnnltSOAP-ENVEnvelopexmlnsSOAP-ENV"http//sc
hemas.xmlsoap.org/soap/envelope/"SOAP-ENVencodin
gStyle"http//schemas.xmlsoap.org/soap/encoding/"
/gt ltSOAP-ENVBodygt ltm GetQuotesResponse
xmlnsm"Some-URI"gt lt GetQuotesResult gt18.0lt/
GetQuotesResult gt lt/m GetQuotesResponse gt
lt/SOAP-ENVBodygtlt/SOAP-ENVEnvelopegt
15UDDI
- UDDI is a central registry for Business and Web
Services - UDDI 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.
16Outline
- What is Web Services
- How to Create Web Services in PB10
- How to Register Web Services in EAServer 5.x
- How to Find Web Services in PB10
- How to Write PB Web Services Client in PB10
- How to Write JSP Web Services Client in PB10
- Demo
- QA
17How to Create Web Services in PB10
- Write PB NVO
- Set NVO as Web Services component
- Deploy PB NVO to EAServer 5.x
- Manage Web Services Component in Sybase
Management Console
18Write NVO
- Create an EAServer component
- Set NVO as Web Services component
- Set NVO as Web Services Component in EAServer
Component Wizard
19Write NVO (cont.)
- Set NVO as Web Services component
- Set NVO as Web Services Component in EAServer
Component Generator - Deploy the NVO to EAServer 5.x
20EAServer Management WebConsole
- http//ServerHost8080/WebConsole/
21Outline
- What is Web Services
- How to Create Web Services in PB10
- How to Register Web Services in EAServer 5.x
- How to Find Web Services in PB10
- How to Write PB Web Services Client in PB10
- How to Write JSP Web Services Client in PB10
- Demo
- QA
22How to Register Web Services in EAS 5.x
- Publish Web Services Component to UDDI server
23Outline
- What is Web Services
- How to Create Web Services in PB10
- How to Register Web Services in EAServer 5.x
- How to Find Web Services in PB10
- How to Write PB Web Services Client in PB10
- How to Write JSP Web Services Client in PB10
- Demo
- QA
24How to Find Web Services
- UDDI Search in PB and JSP Web Services Proxy
Wizard
25How to Find Web Services (cont)
- Search results Businesses/Services
26Outline
- What is Web Services
- How to Create Web Services in PB10
- How to Register Web Services in EAServer 5.x
- How to Find Web Services in PB10
- How to Write PB Web Services Client in PB10
- How to Write JSP Web Services Client in PB10
- Demo
- QA
27Consume Web Services in PB Target
- Generate Web Services Proxy using Web Services
Proxy Wizard - Add pbsoapclient100.pbd to PB Target
- pbsoapclient100.pbd defines 2 new objects
(SoapConnection and SoapException) to handle soap
message - Write PowerScript Code
28Consume Web Services in PB Target (cont)
- pbsoapclient100.pbd has 2 objects
- SoapConnection
- 1. instantiated the proxy object and populated
SOAP options - 2. Set Soap options such as log file,
authorization, proxy etc. - SoapException
- 1. SoapException inherited from PowerBuilder
RuntimeError object - 2. Errors that occur in the execution of a
method of Web service are converted to
SoapException objects and thrown to the calling
script
29Consume Web Services in PB Target (cont)
- SoapConnection cnn // Define SoapConnection
- demo_ieuroport proxy_obj // Define proxy
- long rVal
- real amount
- cnn create SoapConnection //Instantiated
connection - // Create proxy object
- rVal cnn.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 cnn
30Consume Web Services in PB Target (cont)
- Turn on Log if Something Is Wrong
- cnn Create SoapConnectioncnn.setOptions("SoapLo
g'd\webservice.log) - How to Pass HTTP Authentication
- cnn Create SoapConnectioncnn.setOptions("SoapLo
g ,Userid'xxx', Password'yyy') - How to Pass a Proxy Server Which Requires
Username and Password - cnn Create SoapConnectioncnn.setProxyServerOpti
ons(Addressproxy.sybase.com, Userid'xxx',
Password'yyy')
31Outline
- What is Web Services
- How to Create Web Services in PB10
- How to Register Web Services in EAServer 5.x
- How to Find Web Services in PB10
- How to Write PB Web Services Client in PB10
- How to Write JSP Web Services Client in PB10
- Demo
- QA
32How to Write JSP Web Services Client in PB10
- Generate Custom Tag using JSP Web Services Proxy
Wizard - 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. - Write JSP page
- Choose custom tag 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.
- Deploy to JSP Server
33How to Write JSP Web Services Client in PB10
- JSP page
- lt-- Add custom tag to this page --gt
- lt_at_ taglib uri"WEB-INF/tlds/pkg_customer_n_...tld
" prefix"cust" gt - lt-- Define variable to pass into custom tag --gt
- lt! Short custid new Short((short)107)
- org.omg.CORBA.StringHolder address new
org.omg.CORBA.StringHolder() - ... gt
- lt-- Run custom tag --gt
- ltcustof_getcustomer address"lt address gt"
cust_fname"lt cust_fname gt" ... /gt - lt-- Print return results --gt
- lt address.value gtlt/TDgt
- lt pkg_customer_n_customerService_of_getcustomer_
returnValue gt
34How to Write JSP Web Services Client in PB10
- Deploy JSP to any JSP Server
35Demo
- Deploy PB NVO to EAServer 5.x and make it Web
Service - Consume Web Services in PB Target
- Consume Web Service in JSP Target
36Q A