420 likes | 672 Views
PWB509: Web Services in PowerBuilder. Guobi Wu Senior Software Engineer guo-bi.wu@sybase.com July 8, 2003. Jinyou Zhu Senior Software Engineer jyzhu@Sybase.com. Web Services in PowerBuilder. Summary. What is Web Services How to Create Web Services How to Register Web Services
E N D
PWB509: Web Services in PowerBuilder Guobi WuSenior Software Engineerguo-bi.wu@sybase.comJuly 8, 2003 Jinyou ZhuSenior Software Engineerjyzhu@Sybase.com
Web Services in PowerBuilder Summary • What is Web Services • How to Create Web Services • How to Register Web Services • How to Find Web Sevrices • How to Write PB Web Services Client • How to Write JSP Web Services Client • Demo • Q&A
What is Web Services Summary • Web Services is … • Web Services enable PB to interact with other languages, such as Java, .NET • 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 • WSDL • WSDL stands for Web Services Decription 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
What is Web Services Summary • 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
WSDL Elements of WSDL • Types: a container for data type definitions using some type system (such as XSD). • Message: an abstract, typed definition of the data being communicated. • Operation: an abstract description of an action supported by the service. • 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.
WSDL Let’s Read a WSDL Sample • <types> <schema ... > <element name="TradePriceRequest"> <complexType> <all> <element name="tickerSymbol" type="string"/> </all> </complexType> </element> <element name="TradePrice"> <complexType> <all> <element name="price" type="float"/> </all> </complexType> </element> </schema></types>
WSDL Let’s Read a WSDL Sample • <message name="GetLastTradePriceInput"> <part name="body" element="xsd1:TradePriceRequest"/></message><message name="GetLastTradePriceOutput"> <part name="body" element="xsd1:TradePrice"/></message><portType name="StockQuotePortType"> <operation name="GetLastTradePrice"> <input message="tns:GetLastTradePriceInput"/> <output message="tns:GetLastTradePriceOutput"/> </operation></portType><binding name="StockQuoteSoapBinding" type="tns:StockQuotePortType"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/></binding>
SOAP Let’s Read a SOAP Request Sample • POST /StockQuote HTTP/1.1Host: www.stockquoteserver.comContent-Type: text/xml; charset="utf-8"Content-Length: nnnnSOAPAction: "Some-URI"<SOAP-ENV:Envelopexmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body> <m:GetLastTradePrice xmlns:m="Some-URI"> <symbol>SYBASE</symbol> </m:GetLastTradePrice> </SOAP-ENV:Body></SOAP-ENV:Envelope>
SOAP Let’s Read a SOAP Response Sample • HTTP/1.1 200 OKContent-Type: text/xml; charset="utf-8"Content-Length: nnnn<SOAP-ENV:Envelopexmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> <SOAP-ENV:Body> <m:GetLastTradePriceResponse xmlns:m="Some-URI"> <Price>20.0</Price> </m:GetLastTradePriceResponse> </SOAP-ENV:Body></SOAP-ENV:Envelope>
Web Services in PowerBuilder Summary • What is Web Services • How to Create Web Services • How to Register Web Services • How to Find Web Sevrices • How to Write PB Web Services Client • How to Write JSP Web Services Client • Demo • Q&A
How to Create Web Services Create Web Services in PB 9 • Write PB NVO • Deploy PB NVO to EAServer 4.x • Generate Java Stub and Skeleton in Jaguar Manager • Expose Component as Web Services in Web Services Toolkit
Create Web Services in PB 9 Expose component as Web Services in Web Services Toolkit • Create WSDL Document
Create Web Services in PB 9 Expose component as Web Services in Web Services Toolkit • New Web Service
Create Web Services in PB 9 Expose component as Web Services in Web Services Toolkit • Add Addresses and Select Operations
Create Web Services in PB 9 Expose component as Web Services in Web Services Toolkit • Copy generated 2 wsdl files (implementation and interface) from \\EAServer\Webservices\work\wsdlto a place which user can access
How to Create Web Services Create Web Services in PB 10 • Write PB NVO • Set NVO as Web Services component • Deploy PB NVO to EAServer 5.x • Manage Web Services Component in Sybase Management Console
Create Web Services in PB 10 Write PB NVO • Set NVO as Web Services Component in EAServer Component Wizard
Create Web Services in PB 10 Write PB NVO • Set NVO as Web Services component in Properties for EAServer Component Generator
Create Web Services in PB 10 Manage Web Services Component in Sybase Management Console • Sybase Management Console Replaces Web Services Toolkit in EAServer 5.x
Create Web Services in PB 10 Manage Web Services Component in Sybase Management Console • Sybase Management Console Replaces Web Services Toolkit in EAServer 5.x
Web Services in PowerBuilder Summary • What is Web Services • How to Create Web Services • How to Register Web Services • How to Find Web Sevrices • How to Write PB Web Services Client • How to Write JSP Web Services Client • Demo • Q&A
How to Register Web Services Manage Web Services Component in Sybase Management Console • Publish Web Services Component to UDDI server
Web Services in PowerBuilder Summary • What is Web Services • How to Create Web Services • How to Register Web Services • How to Find Web Sevrices • How to Write PB Web Services Client • How to Write JSP Web Services Client • Demo • Q&A
How to Find Web Services Search Web Services from UDDI server in PB 10 • UDDI Search in PB and JSP Web Services Proxy Wizard
How to Find Web Services Search Web Services from UDDI server in PB 10 • UDDI Search in PB and JSP Web Services Proxy Wizard
How to Find Web Sevrices Search Web Services from UDDI Server in PB 10 • UDDI Search in PB and JSP Web Services Proxy Wizard
Web Services in PowerBuilder Summary • What is Web Services • How to Create Web Services • How to Register Web Services • How to Find Web Sevrices • How to Write PB Web Services Client • How to Write JSP Web Services Client • Demo • Q&A
How to Write PB Web Services Client Summary • Generate Web Services Proxy using Web Services Proxy Wizard • Add pbsoapclient90.pbd to PB Target • pbsoapclient90.pbd defines 2 new objects (SoapConnection and soapexception) to handle soap message • Write PowerScript Code
How to Write PB Web Services Client Write PowerScript Code • SoapConnection cnncnn = Create SoapConnectionws_pkg_customer_n_customerserviceport wsobjcnn.CreateInstance(wsobj,"ws_pkg_customer_n_... ")try li_return = wsobj.of_getcustomer(li_custid,...)catch (SoapException e) MessageBox("Exception",e.text)end trydestroy cnn
How to Write PB Web Services Client Write PowerScript Code • Turn on Log if Something Is Wrong • cnn = Create SoapConnectioncnn.setOptions("SoapLog='d:\webservice.log’”) • Let’s Read a Log File
How to Write PB Web Services Client Write PowerScript Code • How to Pass HTTP Authentication • cnn = Create SoapConnectioncnn.setOptions("SoapLog=’’ ,Userid='xxx', Password='yyy'”) • How to Pass a Proxy Server Which Requires Username and Password • cnn = Create SoapConnectioncnn.setProxyServerOptions(“Address=‘proxy.sybase.com’, Userid='xxx', Password='yyy'”)
Web Services in PowerBuilder Summary • What is Web Services • How to Create Web Services • How to Register Web Services • How to Find Web Sevrices • How to Write PB Web Services Client • How to Write JSP Web Services Client • Demo • Q&A
How to Write JSP Web Services Client Summary • Generate Custom Tag using JSP Web Services Proxy Wizard • Write JSP page • Deploy to JSP Server
How to Write JSP Web Services Client Summary Generate Custom Tag using JSP Web Services Proxy Wizard • Do You Want to See How Custom Tag is Implemented: • Open the generated tld file • Extract java files from the generated jar file • Let’s Read TLD File • Let’s Read Java Implementation
How to Write JSP Web Services Client Write JSP page <%-- Add custom tag to this page --%> <%@ taglib uri="WEB-INF/tlds/pkg_customer_n_...tld" prefix="cust" %> <%-- Define variable to pass into custom tag --%> <%! Short custid = new Short((short)107); org.omg.CORBA.StringHolder address = new org.omg.CORBA.StringHolder(); ... %> <%-- Run custom tag --%> <cust:of_getcustomer address="<%= address %>" cust_fname="<%= cust_fname %>" ... /> <%-- Print return results --%> <%= address.value %></TD> <%= pkg_customer_n_customerService_of_getcustomer_returnValue %>
How to Write JSP Web Services Client Deploy to JSP Server • Deployment Server Can Be Any JSP Server
Web Services in PowerBuilder Summary • What is Web Services • How to Create Web Services • How to Register Web Services • How to Find Web Sevrices • How to Write PB Web Services Client • How to Write JSP Web Services Client • Demo • Q&A
Web Services Demo • All Source Codes in This Demo Are Here • Many Thanks to Azeez Abdul, He Wrote Most Samples for This Demo
Q&A ?
SDN Presents CodeXchange Share PowerBuilder 9 Code and Tools • New SDN feature enables community collaboration • Download samples created by Sybase • Leverage contributions of others to exploit PBNI (i.e. PBNI CommonDialog, PBNI OLEObject utilities) • Contribute your own code or start your own collaborative project with input from other PowerBuilder experts • Any SDN member can participate • Log in using your MySybase account via SDN • Join the collaboration already underway • http://powerbuilder.codexchange.sybase.com or via SDN at www.sybase.com/developer • SDN & CodeXchange at TechWave • Technology Boardwalk • Sybase Booth Theater