1 / 82

Web Services

Web Services. Bruce Armstrong TeamSybase bruce.armstrong@teamsybase.com. Agenda. • Introduction to Web Services • Creating .NET Web Services • Consuming Web Services • Web Service DataWindow • Q & A. Introduction to Web Services. Introduction to Web Services.

gusty
Download Presentation

Web Services

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. Web Services Bruce Armstrong TeamSybase bruce.armstrong@teamsybase.com

  2. Agenda • • Introduction to Web Services • • Creating .NET Web Services • • Consuming Web Services • • Web Service DataWindow • • Q & A

  3. Introduction to Web Services

  4. Introduction to Web Services • Facilitate communication between systems • Different platforms • Different programming languages • Through firewalls easily • Self descriptive API • Self descriptive data

  5. What are Web Services? • A collection of operations that can be described, published, located, and accessed over a network using standardized XML messaging • Proposed to World Wide Web Consortium (W3C) in Mar 2001 • http://www.w3c.org • Web Services utilize XML making them both platform and language independent • XML gives us a mechanism for making cross-platform and/or cross-language communications

  6. Web Service Components • The primary components that make up Web Services are: • WSDL – Web Services Description Language • Used to describe Web services • SOAP – Simple Object Access Protocol • Used for sending and receiving messages from Web services

  7. Describing Web Services • Why does a Web service need to be described? • Web services could be used by anyone, anywhere, using any language on any platform • A description allows a developer to know how to interact with a Web service • PowerBuilder provides tools to read and integrate WSDL • Web services are described using Web Services Description Language (WSDL) • WSDL is written in XML • Usually a developer of a Web Service does not have to manually write WSDL • PowerBuilder 11 creates the ASMX, DISCO and WSDL

  8. CREATING .NET Web Services

  9. PowerBuilder/.Net Web Services • PowerBuilder gives you the choice of outputting PowerScript code as an • Assembly • Web Service • The only difference PowerBuilder Web Service creation now versus back in Version 9.0 of PowerBuilder is EAServer is no longer a requirement • These Web Services are deployed to your Microsoft IIS Web Server

  10. .Net Web Service Target

  11. Web Service Virtual Directory • The wizard is virtually the same as for .NET assemblies, etc. • You must specify a virtual directory name for your Web Service however because it will live on IIS

  12. .Net Web Service Wizard Output • PBL, Application Object, Project, NVO

  13. NVOs – Code as you normally would

  14. Web Service Project • Wizard elections may always be changed in the Project:

  15. Web Service Deployment Options • Directly to IIS or create an MSI install File

  16. Web Service Specifics • You must select which methods you want to expose • You can view WSDL and test your Web Service

  17. Viewing WSDL • Must deploy your .NET Web Service target first • Project View WSDL button OR • In a browser • http://hostname/virtdirname/service.asmx?WSDL

  18. WSDL Example

  19. More WSDL – Message, Operation, Service, Port

  20. IIS Directory – What is here?

  21. Web Service Virtual Root Directory

  22. Global.asax file • A source file where developers can add application level logic into their Web applications • Application events such as Application_Start, Application_End, Session_Start, Session_End live here • Located at the root of a particular Web application's virtual directory tree • Automatically parsed and compiled into a dynamic .NET Framework class • The first time any resource or URL within the application namespace is activated or requested

  23. Global.asax file • Configured to automatically reject any direct URL request so that external users cannot download or view the code within <%@ Application Codebehind="Global.asax.cs" Inherits="PBWebApp.Global" %>

  24. DISCO Files • DISCO is a Microsoft technology for publishing and discovering Web Services • DISCO files make it possible to discover the Web Services exposed on a given server • DISCO files make it possible to discover the capabilities of each Web Service (via documentation) and how to interact with it • DISCO files live in the Web Application’s virtual root <?xml version="1.0" encoding="utf-8"?> <discovery xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/disco/"> <contractRef ref="http://localhost/webservice/n_webservice.asmx?wsdl" docRef="http://localhost/webservice/n_webservice.asmx" xmlns="http://schemas.xmlsoap.org/disco/scl/" /> </discovery>

  25. ASPX files • ASP.NET provides support for Web Services with the.asmx file (a wrapper to your Web Service) • Similar to an .aspx files we talked about with PowerBuilder/WebForm applications • From a browser, enter the following: • http://hostname/virtdirname/service.asmx • OR use the following that was generated on deployment of the Web Service: • C:\Inetpub\wwwroot\virtdirname\TestWebService.htm • OR in the deployment project click the Run Web Service button

  26. List of Web Service Operations • The ASMX file lists your Web Service methods • Clicking a link takes you to a test “harness” for that method

  27. Testing the Web Service

  28. Test Results

  29. Why Did We Do This? • Interoperability • You now have a Web Service ready to be accessed from: • Java • C# • VB (VB.NET) • PowerBuilder • …

  30. Sample: Calling PB Web Service from C#

  31. CONSUMING Web Services

  32. Accessing Web Services • Once you have the details and have built your web service consumer application, how do you call that web service’s methods? • Create a Simple Object Access Protocol (SOAP) message • PowerBuilder provides two options capable of reading and writing SOAP messages • “Legacy” EasySoap PBNI extension • “New” .NET Engine

  33. SOAP • An XML-based communications protocol • “Everything is XML” • Industry standard for cross-platform distributed messaging • Defined by World Wide Web Consortium (W3C)

  34. Web Service Consumption • Consuming a Web Service from a PowerBuilder client is very similar to using a PowerBuilder/EAServer component • A proxy is needed, but Web Services require a Web Service proxy, not an EAServer proxy • A connection is needed, but Web Services require a Soap Connection • The Web Service is similar to an NVO/Component in that it is a container of methods which could be called via SOAP messages Continued …

  35. Web Service Consumption • Invoking Web services through SOAP requires: • Serialization and deserialization of data types • The building and parsing of XML-based SOAP messages • A PowerBuilder Web Service client proxy performs these tasks for you eliminating the need to have extensive knowledge of : • The SOAP specification and schema • The XML Schema specification • The WSDL specification and schema

  36. .Net Web Service Engine Flow Prerequisite: .NET 2.0 Framework SDK MUST be installed on development machine. .NET 2.0 Framework (Runtime) MUST be installed on both development and deployment machine.

  37. Web Service Proxy Wizard

  38. Choose the Web Service Engine

  39. Specify WSDL

  40. Select a Service From WSDL

  41. Define Prefix for Proxy (Optional)

  42. Specify Project Name and Library

  43. Specify PBL for generated proxy • It is a standard practice to store your proxies in a separate PBL in your library list

  44. Proxy Project • Upon completion of the WSPW, the new project is visible in the System Tree, and the project will be open in the painter • Next, deploy the project

  45. Use Proxy Servers? • If your company uses a Proxy Server to bridge between you and the Firewall, visit the Tools  System Options dialog • Input the name of your Proxy Server, port, your user id and password to that proxy server • This is for design-time Internet connections only

  46. The Web Service Proxy • System Tree (expanded), following the deploy of the proxy project • The function(s) available from the Web Service will be visible under the proxy • Be sure you understand that the proxy project is separate from the actual proxy object

  47. Use of Aliases in Proxy • PowerBuilder is not case sensitive • XML (SOAP) and .NET are case sensitive • To get around that difference, each method in the proxy uses an alias • The string that follows “alias for” contains the case-sensitive name and the signature of the corresponding XML or SOAP method

  48. Exported Web Service Proxy • Note the “alias for” clauses in the function or subroutine declarations

  49. .Net Web Service Engine – Files Created from Proxy

  50. Web Service Runtime Engines • EasySoap Engine – pbsoapclient110.pbd/pbx • This engine is backward compatible with the PB9/PB10 Web Service engine • It can work on machines that don’t have the .NET framework • .NET Engine – pbwsclient110.pbd/pbx • This is new .NET SOAP engine • Both of the above define two classes: • SoapConnection • SoapException

More Related