98
Sybase Symposium 15 November 2007 Diamant Brussels Web Services Workshop Dave Fish Senior Software Engineer Sybase Inc.

Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium15 November 2007Diamant Brussels

Web Services Workshop

Dave FishSenior Software EngineerSybase Inc.

Page 2: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium15 November 2007Diamant Brussels

Creating .NET Web Services

Page 3: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 3

Proprietary Interfaces & Manual Intervention

Re-Seller Manufacturer

= Component

Salespeople

Inventory Clerk

Purchasing Agent

Page 4: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 4

The Solution

If the Manufacturer exposes some of his components/methods to the outside world, that would enable the re-seller’s applications to directly call those methods That is why Web Services were createdIn reality, Web Services have expanded to more than Business-to-Business (B2B) applicationsCompanies are finding Web Services to be a good tool to enable internal systems communications as well

Page 5: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 5

Business With Web Services

Re-Seller Manufacturer

= Component now as a

Web Service

Salespeople

Inventory Clerk Purchasing Agent

IIS

Page 6: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 6

What are Web Services?

A collection of operations that can be described, published, located, and accessed over a network using standardized XML messagingProposed to World Wide Web Consortium (W3C) in Mar 2001

http://www.w3c.org

Web Services utilize XML making them both platform and language independentXML gives us a mechanism for making cross-platform and/or cross-language communications

Page 7: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 7

Web Services Components

The primary components that make up Web Services are:

WSDL – Web Services Description LanguageUsed to describe Web services

SOAP – Simple Object Access ProtocolUsed for sending and receiving messages from Web servicesMore on SOAP in the next module

Page 8: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 8

Describing the Web Service

Why does a Web service need to be described?Web services could be used by anyone, anywhere, using any language on any platformA description allows a developer to know how to interact with a Web service

PowerBuilder provides tools to read and integrate WSDLWeb services are described using Web Services Description Language (WSDL)WSDL is written in XMLUsually a developer of a Web Service does not have to manually write WSDL

PowerBuilder 11 will create the ASMX, DISCO and WSDL

Page 9: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 9

PowerBuilder/.NET Web Services

PowerBuilder gives you the choice of outputting PowerScript code as an

AssemblyWeb 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

Page 10: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 10

.NET Web Service Target

Page 11: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 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

Page 12: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 12

.NET Web Service Wizard Output

PBL, Application Object, Project, NVO

Page 13: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 13

NVOs – Business As Usual

Page 14: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 14

Web Service Project

Wizard elections may always be changed in the Project:

Page 15: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 15

Web Service Deployment Options

Can go directly to IIS or create a MSI installer

Page 16: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 16

Web Service Specifics

You must select which methods you want to exposeYou can view WSDL and test your Web Service here too

Page 17: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 17

Deployment Progress

Seen via the output pane

Page 18: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 18

Viewing WSDL

Must deploy your .NET Web Service target first

Project View WSDL button OR

In a browserhttp://hostname/virtdirname/service.asmx?WSDL

http://localhost/techwave07_service/n_techwave07_ws.asmx?WSDL

Page 19: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 19

WSDL Example

Page 20: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 20

More WSDL – Message, Operation, Service, Port

Page 21: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 21

IIS Directory: What Is Here?

Page 22: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 22

Web Service Virtual Root Directory

Page 23: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 23

Global.asax File

A source file where developers can add application level logic into their Web applicationsApplication events such as Application_Start, Application_End, Session_Start, Session_End live hereLocated at the root of a particular Web application's virtual directory treeAutomatically parsed and compiled into a dynamic .NET Framework class

The first time any resource or URL within the application namespace is activated or requested

Configured to automatically reject any direct URL request so that external users cannot download or view the code within

Page 24: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 24

DISCO Files

DISCO is a Microsoft technology for publishing and discovering Web ServicesDISCO files make it possible to discover the Web Services exposed on a given serverDISCO files make it possible to discover the capabilities of each Web Service (via documentation) and how to interact with itDISCO files live in the Web Application’s virtual root

Page 25: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 25

ASMX 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 applicationsFrom a browser, enter the following:

http://hostname/virtdirname/service.asmxhttp://localhost/techwave07_service/n_techwave07_ws.asmxOR use the following that was generated on deployment of the Web Service:

C:\Inetpub\wwwroot\techwave07_service\TestWebService.htmOR in the deployment project click the Run Web Service button

Page 26: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 26

List of Web Service Operations

The ASMX file lists your Web Service methodsClicking a link takes you to a test “harness” for that method

Page 27: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 27

Testing The Web Service

Page 28: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 28

Test Results

Page 29: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 29

Why Did We Do This?

InteroperabilityYou now have a Web Service ready to be accessed from:

JavaC#VB (VB.NET)PowerBuilder…

Page 30: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 30

Sample: Calling PB Web Service From C#

Page 31: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium15 November 2007Diamant Brussels

Consuming .NET Web Services

Page 32: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 32

Accessing the Web Service

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) messagePowerBuilder provides two options capable of reading and writingSOAP messages

“Legacy” EasySoap PBNI extension“New” .NET Engine

Page 33: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 33

SOAP

An XML-based communications protocol“Everything is XML”

Industry standard for cross-platform distributed messaging

Defined by World Wide Web Consortium (W3C)

Page 34: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 34

Web Service Consumption

Consuming a Web Service from a PowerBuilder client is very similar to using a PowerBuilder/EAServer componentA proxy is needed, but Web Services require a Web Service proxy, not an EAServer proxyA connection is needed, but Web Services require a Soap ConnectionThe Web Service is similar to an NVO/Component in that it is a container of methods which could be called via SOAP messages

Continued …

Page 35: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 35

Web Service Consumption

Invoking Web services through SOAP requires:Serialization and deserialization of data typesThe 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 schemaThe XML Schema specificationThe WSDL specification and schema

Page 36: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 36

.NET Web Service Engine Flow

At design time:

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.

At runtime:

ProxyWS Proxy Wizard/GeneratorWSDLFile

A .NET Assembly

RemoteServicesProxy pbwsclient110.pbd/pbx A .NET

Assembly

Page 37: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 37

Web Service Proxy Wizard

Page 38: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 38

Choose The Web Service Engine

Page 39: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 39

Locate WSDL

Page 40: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 40

Searching a UDDI

Page 41: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 41

Selecting From UDDI Search Results

Page 42: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 42

WSDL Selection: Post UDDI Search

Page 43: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 43

Select A Service From WSDL

Page 44: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 44

Optionally Define A Prefix For The Proxy

Page 45: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 45

Define Proxy Project Name and Location

Page 46: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 46

Set Location For Proxy When Built

It is a standard practice to store your proxies in a separate PBL in your library list

Page 47: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 47

Post Web Service Proxy Wizard

Upon completion of the WSPW, the new project is visible in the System Tree, and the project will be open in the painterNext, deploy the project

Page 48: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 48

Use Proxy Servers?

If your company uses a Proxy Server to bridge between you and the Firewall, visit the Tools System Options dialogInput the name of your Proxy Server, port, your user id and password to that proxy serverThis is for design-time Internet connections only

Page 49: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 49

The Web Service Proxy

System Tree (expanded), following the deploy of the proxy projectThe function(s) available from the Web Service will be visible under the proxyBe sure you understand that the proxy project is separate from the actual proxy object

Web Service Proxy

Page 50: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 50

Use Of Aliases In Proxies

PowerBuilder is not case sensitiveXML (SOAP) and .NET are case sensitiveTo 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

Page 51: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 51

Exported Web Service Proxy

Note the “alias for” clauses in the function or subroutine declarations

Page 52: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 52

.NET Web Service Option: Files Created from Proxy

Page 53: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 53

Web Services Runtime Engines

EasySoap Engine – pbsoapclient110.pbd/pbxThis engine is backward compatible with the PB9/PB10 Web Service engineIt can work on machines that don’t have the .NET framework

.NET Engine – pbwsclient110.pbd/pbxThis is new .NET SOAP engine

Both of the above define two classes:SoapConnectionSoapException

Page 54: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 54

What Was that PBX Reference?

An extension to PowerBuilder functionality created using the PowerBuilder Native Interface (PBNI)Before 10.5, a PBNI extension (*.pbx or *.dll) developer had to:

Use the pbx2pbd utility to create a PBD file from an extensionBe sure to put the extension file (PBX) in the application's search path and add the PBD file to the target's library list

Now there are fewer steps:Import the *.pbx directly into your *.pbl’s using the System TreeMust still deploy the extension in the application’s path

Page 55: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 55

Importing PowerBuilder Extensions

Prior to PB 10.5, to gain aSoapConnection, you addedpbsoapnnn.pbd to your library listPbsoapnnn.pbd was a PBNIextension for EasySoapNow you can import the *.pbx directly to a PBLTo do so, right-click over aPBL

Page 56: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 56

Choosing The Appropriate Extension File

Pbwsclient110.pbx is the extension for the .NET Web Service enginePbsoapclient110.pbx is the extension for EasySoap

../Sybase/Shared/PowerBuilder

Page 57: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 57

Important Notes About These Imports

Using pbwsclient110.pbx requires the .NET 2.0 Framework on design-time and runtime machinesBoth extension files contain the same objects, and you use these objects and their methods in similar waysThe Sybase\Shared\PowerBuilder directory contains PBD versions of the extension files that may still be used instead of importing the extensions (add PBDs to library list instead)When you create a Web service client application, you must deploy the extension file that you use along with the client executable to a directory in the application's search path

The Runtime Packager tool automatically includes the extension files required by your Web service applications

Page 58: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 58

PowerBuilder Runtime Packager

Will help to ensure PBNI extensions are deployed to your end users:

Page 59: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 59

Result Of PBX Import

Following the import of the.NET extension, you will see two new objects in the System Tree:

soapconnectionsoapexception

Notice the createinstance( ) method in soapconnection

Just like an EAServer proxy

Page 60: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 60

Connection Code

After importing the SoapConnection object, you are ready to write code to communicate with the Web ServiceBegin by instantiating the soapconnection object:

Page 61: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 61

SoapConnection Methods

New methods were added to SoapConnection in PowerBuilder 10.5Prior to 10.5, most connection options were passed in as arguments to the SetOptions( ) method of SoapConnectionNow, there are individual methods you may callFor EasySoap use:

SetSoapLogFile( )SetTimeout( )UseConnectionCache( )

For .NET Web Services, see the following pages

Page 62: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 62

SoapConnection: SetBasicAuthentication()

Syntax:conn.SetBasicAuthentication (string domain, string userID, string password)

Usage:Used to pass a userid and password to an https connection used by the Web ServiceOnly available for .NET Web Services

Page 63: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 63

SoapConnection: SetClientCertificateFile( )

Syntax:conn.SetClientCertificateFile (string filename)

Usage:Used to pass a user certificate needed to connect to the Web ServiceOnly available for .NET Web Services

Page 64: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 64

SoapConnection: SetTimeout( )

Syntax:conn.SetTimeout (long seconds)

Usage:Used to set a timeout value for the Web Service communications.NET or EasySoap

Page 65: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 65

SoapConnection: UseIntegratedAuthentication()

Syntax:conn.UseIntegratedAuthentication (boolean useIWA)

Usage:Uses integrated Windows Authentication to connect to a Web ServiceOnly available for .NET Web Services

Page 66: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 66

SoapConnection: RemoveAuthentication( )

Syntax:conn.RemoveAuthentication ()

Usage:Removes authentication for a Web Service connection

This method clears Basic, Digest, and Integrated Windows Authentication information

Only available for .NET Web Services

Page 67: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 67

SoapConnection: SetProxyServer( )

Syntax:conn.SetProxyServer (string address, string userID, string password)

Address = Proxy Server address (http://hostname:port/path)conn.SetProxyServer (string hostname, long port, string userID, string password)

Usage:Use this method if you are talking to a Web Service but must first go through a Proxy Server (on the client-side)An alternative is to use the SetProxyServerOptions( ) method

Page 68: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 68

Securing Web Services

Securing Web Services has been secondary from the beginning of the specificationHowever, you have seen some security measures are in place

The ability to secure a Web Service:Basic authentication (user id and password)Use of digital certificates

You may also secure a Web Service through the use of SOAP HeadersThis section will show you how to use SOAP Header authentication

Page 69: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 69

Making The Web Service Call

Declare a reference variable of type Web Service proxyCreate an instance of the Web Service proxy

Page 70: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 70

Sample SOAP Message

Use of SOAP Headers is optionalHere, I may be calling a Web Service method named GetData, asking for information about Customer # 101:

Page 71: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 71

SOAP Message With Header

The exact number of tags you put into the SOAP Header is up to your discretion as the developer of the Web Service:

Page 72: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 72

Sample C# Code: SOAP Header Class

My header, AuthHeader inherits from the SoapHeader classContains two fields (instance variables) that will map to tags in the SOAP Header

Page 73: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 73

Web Service Has Reference To Header Class

Page 74: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 74

Method Of Web Service Using Header

Page 75: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 75

Proxy Created Artifacts

Since this Web Service uses SOAP Headers, the Proxy generator created some additional artifacts

SetAuthHeaderValue( ) method on the proxy itselfAuthHeader NVO containing properties such as UserNameand Password

Page 76: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 76

PowerBuilder Using SOAP Header

Page 77: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 77

Result With SOAP Headers

Call to the SOAP Header “Authenticated” Web Service was successful

Page 78: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 78

Note About SOAP Headers

Be aware that authenticating callers by encoding plaintext user names and passwords in SOAP Headers is not secure

To secure SOAP Header information you could:

Encrypt SOAP messages by writing a SOAP extension that unencrypts requests and encrypts responses

Use SSL / HTTPS to publish the Web Service

Page 79: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium15 November 2007Diamant Brussels

Web Service DataWindows

Page 80: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 80

Web Service as DataWindow Data Source

In PowerBuilder 11, you can use a Web Service as the data source for DataWindow objects

Supports a disconnected client modelEliminates requirement that database vendor’s client software reside on end-user machineWeb Service ‘result set’support

Page 81: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 81

Web Service DataWindows

Are an extension of the Web Services support that has been in PowerBuilder since Version 9.0

Uses the .NET Web Service engineCreates a .NET assembly to do the work behind the scenes

Web Service DataWindows are modeled on the way the Stored Procedure DataWindow worksTwo components:

Design-time component that allows you to browse, select a Web Service, then a specific methodRun-time component that

Retrieves data and maps to DataWindow columnsUpdates data mapping columns to Web Service method inputs

Page 82: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 82

Restrictions On Web Service Methods

The return of the Web Service method must be:Simple types such as Integer, String, DateTime

DWO will have a single column/rowArray of simple types

DWO will nave n rows of a single column depending on the size of the array

Structure of simple typesDWO will have 1 row with n columns depending on the number of variables in the structure

Array of structureDWO will have n rows, n columns

Some Web Service methods will not work with the DataWindow

Page 83: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 83

Other Web Service DataWindow Notes

Web Service DataWindows will allow Retrieval Arguments

If the Web Service method has input parameters

Query Mode will not be supportedThe Web Service method metadata is used to create the actual DataWindow objectYou will call dw_1.Retrieve( ) just as you do today

Page 84: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 84

Presentation Styles supported:

RichText and OLE are not supported

Supported Presentation Styles

Page 85: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 85

First, select a WSDL file describing the Web Service

Enter the URL to a WSDL, ASMX, or XML file, or browse a mapped drive for a WSDL file

The file selected should be in a publicly accessible location for all members of the development team

Selecting A WSDL File

Continued …

Page 86: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 86

Provide A .NET Assembly Name

The Assembly File serves as an interface between the DataWindow and the Web Service

Name the Assembly File If you do not name the Assembly file, the wizard will select a name based on the name of the WSDL file entry

Continued …

Page 87: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 87

Next, you must select a service described in the WSDL and then one of its public methods

Select Web Service / Web Service Method

Page 88: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 88

Select Web Service Method OutputSelect which of the methods arguments or its return value to use as the result set

Continued …

Page 89: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 89

After completing the wizard the DataWindow is displayed

Finished Web Service DataWindow

Page 90: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 90

PowerBuilder automatically generates a .NET assembly (dll) used to interact with the Web Service at runtime

The generated .NET dll must be copied along with the application executable and required PowerBuilder runtime DLLs for Web Service applications

Interaction With The Web Service

DataWindowPainter

PowerBuilder Web Service

support using the .NET engine

Metadata

WSDLA DataWindowObject

Generated.NET

Assembly1

54

6 2 3

Page 91: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 91

New WSConnection Object

Some Web services support or require a user ID and password, and other session-related propertiesThe wsconnection can provide this information:

Page 92: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 92

Sample WSConnection Code

Page 93: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 93

Updates On Web Service DataWindows

There are no transaction standards provided with Web ServicesWeb Services are inherently stateless

Call a method, get a response, finished

Given the above limitations, if updating data via a Web Service DataWindow, you will use the “Trust”methodology

Basically, you are throwing the data “over the fence” to the Web Service and trusting he will do the right thingFor example, if you have a DataWindow doing an insert, update and delete, and the call to the Web Service method for the delete fails, the Web Service DataWindow doesn’t retain knowledge of the other two operations

Page 94: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 94

Defining Update Properties

As mentioned before, the Web Service DataWindow was modeled from the Stored Procedure DataWindowThe DataWindows Rows menu item now has a new item for Web Services Updates…Instead of mapping the DataWindow to a particular Stored Procedure, you will map the DataWindow (columns) to a particular Web Service method input parameter(s)

Page 95: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 95

Similar to Stored Procedure update options

Web Service DataWindow Updates

Page 96: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 96

Web Service Error Handling

New WSError event is analogous to the existing DataWindow DbError event when using a Web Service data source

Exception message returned from the methodErrorMessage

Name of the Web service method invokedMethod

The WSDL file, the URL that defines the Web service, or the assembly that is used access the Web service

WSInfo

Name of the buffer being accessed while the error occurred

BufferName

Row number (or 0 if not applicable such during

RownumType of operation (Retrieve, Update, Insert, Delete, …)

OperationDescriptionArgument

Page 97: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 97

Web Service Tracing

You can also perform limited tracing of the Web Service DataWindowDo so by adding a key-value pair to PB.INI

[DataWindow] sectiondebug_ws_metadata = 1

Page 98: Web Services Workshop - pudn.comread.pudn.com/downloads432/ebook/1824633/pbWebServices.pdf · 2010. 6. 18. · PowerBuilder 11 will create the ASMX, DISCO and WSDL. Sybase Symposium

Sybase Symposium 2007 – November 15 - Brussels 98