1 / 36

PWB 519: Development of Web Service in PB 10

PWB 519: Development of Web Service in PB 10. Jin-You Zhu Sr. Software Engineer Jyzhu@sybase.com August 15-19, 2004. The Enterprise. Unwired. The Enterprise. Unwired. Industry and Cross Platform Solutions. Manage Information. Unwire Information. Unwire People.

alexis
Download Presentation

PWB 519: Development of Web Service in PB 10

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. PWB 519: Development of Web Service in PB 10 Jin-You Zhu Sr. Software Engineer Jyzhu@sybase.com August 15-19, 2004

  2. The Enterprise. Unwired.

  3. The Enterprise. Unwired. Industry and Cross Platform Solutions Manage Information Unwire Information Unwire People • 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. Development of Web Service in PB 10 -- Outline • 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 • Q&A

  5. What 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

  6. 3 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

  7. WSDL • 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.

  8. WSDL – PortType & Binding <portType name="StockQuotesSoap"> <operation name="GetStockQuotes"> <input name="GetQuotes" message="s0:GetQuotesSoapIn" /> <output name="GetQuotes" message="s0:GetQuotesSoapOut" /> </operation> </portType> <binding name="StockQuotesSoap" type="s0:StockQuotesSoap"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> <operation name="GetStockQuotes"> <soap:operation soapAction="http://swanandmokashi.com/GetQuotes" style="document" /> <input name="GetQuotes"> <soap:body use="literal" /> </input> <output name="GetQuotes"> <soap:body use="literal" /> </output> </operation> </binding>

  9. WSDL -- Message <message name="GetQuotesSoapIn"> <part name="parameters" element="s0:GetQuotes" /> </message> <message name="GetQuotesSoapOut"> <part name="parameters" element="s0:GetQuotesResponse" /> </message> ….

  10. WSDL -- Types <types> <s:schema elementFormDefault="qualified" targetNamespace="http://swanandmokashi.com"> <s:element name="GetQuotes"> <s:complexType> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="QuoteTicker" type="s:string" /> </s:sequence> </s:complexType> </s:element> <s:element name="GetQuotesResponse"> <s:complexType> <s:sequence> <s:element minOccurs="0" maxOccurs="1" name="GetQuotesResult" type=“:string" /> </s:sequence> </s:complexType> </s:element> </s:schema> </types>

  11. WSDL – Services & Ports <service name="StockQuotes"> <port name="StockQuotesSoap" binding="s0:StockQuotesSoap"> <soap:address location="http://www.swanandmokashi.com/HomePage/WebServices/StockQuotes.asmx" /> </port> </service>

  12. 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.

  13. SOAP – Request Message <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body> <m:GetQuotes xmlns:m="http://swanandmokashi.com"> <m:QuoteTicker>SY</m:QuoteTicker> </m:GetQuotes> </SOAP-ENV:Body> </SOAP-ENV:Envelope>

  14. SOAP – Response Message 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: GetQuotesResponse xmlns:m="Some-URI"> < GetQuotesResult >18.0</ GetQuotesResult > </m: GetQuotesResponse > </SOAP-ENV:Body></SOAP-ENV:Envelope>

  15. UDDI • 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.

  16. Outline • 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 • Q&A

  17. How 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

  18. Write NVO • Create an EAServer component • Set NVO as Web Services component • Set NVO as Web Services Component in EAServer Component Wizard

  19. Write 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

  20. EAServer Management WebConsole • http://ServerHost:8080/WebConsole/

  21. Outline • 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 • Q&A

  22. How to Register Web Services in EAS 5.x • Publish Web Services Component to UDDI server

  23. Outline • 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 • Q&A

  24. How to Find Web Services UDDI Search in PB and JSP Web Services Proxy Wizard

  25. How to Find Web Services (cont) Search results – Businesses/Services

  26. Outline • 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 • Q&A

  27. Consume 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

  28. Consume 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

  29. Consume 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

  30. Consume Web Services in PB Target (cont) • Turn on Log if Something Is Wrong • cnn = Create SoapConnectioncnn.setOptions("SoapLog='d:\webservice.log’”) • 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'”)

  31. Outline • 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 • Q&A

  32. How 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

  33. How to Write JSP Web Services Client in PB10 • 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 %>

  34. How to Write JSP Web Services Client in PB10 • Deploy JSP to any JSP Server

  35. Demo • Deploy PB NVO to EAServer 5.x and make it Web Service • Consume Web Services in PB Target • Consume Web Service in JSP Target

  36. Q & A ?

More Related