47
Implementing and Implementing and Accessing Web Services Accessing Web Services Using Visual Basic 6.0 Using Visual Basic 6.0 and the Visual Studio and the Visual Studio SOAP Toolkit SOAP Toolkit Karthik Ravindran Karthik Ravindran Developer Support Engineer Developer Support Engineer VB/ASP Web Database VB/ASP Web Database Microsoft Corporation Microsoft Corporation

Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

Embed Size (px)

Citation preview

Page 1: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

Implementing and Accessing Implementing and Accessing Web Services Using Visual Web Services Using Visual Basic 6.0 and the Visual Studio Basic 6.0 and the Visual Studio SOAP Toolkit SOAP Toolkit

Karthik RavindranKarthik RavindranDeveloper Support EngineerDeveloper Support EngineerVB/ASP Web DatabaseVB/ASP Web DatabaseMicrosoft CorporationMicrosoft Corporation

Page 2: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

2

AgendaAgenda BackgroundBackground

Web ServicesWeb Services Current distributed object infrastructuresCurrent distributed object infrastructures

SOAP SOAP IntroductionIntroduction Messaging ArchitectureMessaging Architecture Advantages and disadvantagesAdvantages and disadvantages

The MicrosoftThe Microsoft®® Visual Studio Visual Studio®® SOAP Toolkit SOAP Toolkit Introduction - What is it ?Introduction - What is it ? What does it includeWhat does it include TerminologyTerminology TechnologiesTechnologies

Page 3: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

3

AgendaAgenda (2) (2) ROPE – Remote Object Proxy EngineROPE – Remote Object Proxy Engine

Introduction – What is it ?Introduction – What is it ? Purpose and usagePurpose and usage ROPE ObjectsROPE Objects

Labs, process and code WalkthroughsLabs, process and code Walkthroughs Setting up a VB6 Web Service using the SOAP ToolkitSetting up a VB6 Web Service using the SOAP Toolkit Setting up VB6 ROPE clients to access a Web ServiceSetting up VB6 ROPE clients to access a Web Service Implementing a simple VB6 Web Services Discovery client Implementing a simple VB6 Web Services Discovery client

using the ROPE Objectsusing the ROPE Objects Returning ADO recordsets in SOAP messaging Returning ADO recordsets in SOAP messaging

Q/AQ/A

Page 4: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

4

Web ServicesWeb Services A major shift in application developmentA major shift in application development Distributing and integrating application logic over

the Web Delivering software as a service accessible to Delivering software as a service accessible to

anyone, anywhere, at anytimeanyone, anywhere, at anytime Joining tightly coupled component technologies with Joining tightly coupled component technologies with

loosely coupled Internet messaging standardsloosely coupled Internet messaging standards Components required to realize the concept ofComponents required to realize the concept of

Web Services:Web Services: A standard messaging format for requests and A standard messaging format for requests and

responsesresponses A service description languageA service description language A Web Services Discovery Language/mechanismA Web Services Discovery Language/mechanism

Page 5: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

5

Distributed Object InfrastructuresDistributed Object Infrastructures Distributed object infrastructure = component Distributed object infrastructure = component

technology + wire protocoltechnology + wire protocol Current distributed object infrastructures: Current distributed object infrastructures:

COM/DCOM, Java RMI/JRMP, CORBA/GIOPCOM/DCOM, Java RMI/JRMP, CORBA/GIOP Disadvantages of proprietary distributed Disadvantages of proprietary distributed

object infrastructures:object infrastructures: Vendor specificVendor specific Platform specificPlatform specific Lack of interoperabilityLack of interoperability Administrative costsAdministrative costs

Custom runtimeCustom runtime Configuring firewallsConfiguring firewalls

Page 6: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

6

Introduction to SOAPIntroduction to SOAP What is SOAP ?

An Internet standard specification, the goal of which is to define a platform and vendor-neutral WIRE PROTOCOL based on Internet standard protocols [HTTP & XML] to define and access Web Services

Why SOAP ?Why SOAP ? Role of a ‘Wire Protocol’ in accessing distributed object

services Vendor and/or platform-specific nature of current wire

protocols hinder interoperability

SOAP Goals: SOAP Goals: Specify a platform independent Internet based format to Specify a platform independent Internet based format to

package requests for services exposed by Web Services, package requests for services exposed by Web Services, and responses generates by Web Services [XML] and responses generates by Web Services [XML]

Specify a platform independent format to describe Web Specify a platform independent format to describe Web Services [ XML ]Services [ XML ]

Specify a platform independent Wire protocol [HTTP]Specify a platform independent Wire protocol [HTTP]

Page 7: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

7

Introduction to SOAPIntroduction to SOAP (2) (2)

What SOAP is NOT ?What SOAP is NOT ?

SOAP is not a replacement for any of the current SOAP is not a replacement for any of the current component technologiescomponent technologies

It does not specify how key infrastructural It does not specify how key infrastructural elements of a Distributed Object Infrastructure elements of a Distributed Object Infrastructure need to be implemented [ eg: Distributed garbage need to be implemented [ eg: Distributed garbage collection, Object activation etc. ]collection, Object activation etc. ]

Page 8: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

8

Accessing a Web Service Using SOAPAccessing a Web Service Using SOAP

                                                            

CLIENT

WS

WS

WS

WEB SERVICE PROVIDER

SOAP REQUEST PAYLOAD

SOAP RESPONSEPAYLOAD

SOAP RESPONSEPAYLOAD

INTERNET/INTRANET

1 – Obtain/Examine SDL and Generate SOAP REQUEST

2 – Transmit REQUEST Payload[ HTTP POST ]

3 – ReceiveRequest Payloadon HTTP Port 80

4 – Parse Request, Process Request, and Generate SOAP RESPONSE

5 – Transmit RESPONSE Payload

6 – Receive andParse RESPONSE

SDL

SDL

SDL

Page 9: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

9

The SOAP Request PayloadThe SOAP Request Payload A standard XML-based format to describe a SOAP A standard XML-based format to describe a SOAP

request for a Web Servicerequest for a Web Service Provides all the information required by the Web Provides all the information required by the Web

Service provider to process the requestService provider to process the request General format of a SOAP request: General format of a SOAP request:

HTTP Header SOAP Action

<SOAP-ENV:Envelope> <SOAP-ENV:Header> <!-- Soap Header is optional --> </SOAP-ENV:Header> <SOAP-ENV:Body> <!-- Serialized method invocation data --> </SOAP-ENV:Body></SOAP-ENV:Envelope>

Page 10: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

10

The SOAP Response PayloadThe SOAP Response Payload

A standard XML-based format to describe the Response generated by a Web Service

Contains information that is to be passed back to the client

General format of a SOAP response:

HTTP Header

<SOAP-ENV:Envelope> <SOAP-ENV:Body> <!-- Serialized Response Data --> </SOAP-ENV:Body></SOAP-ENV:Envelope>

Page 11: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

11

Advantages of SOAP Advantages of SOAP

Tremendously lightweight. Requires two Tremendously lightweight. Requires two fundamental capabilities:fundamental capabilities: Capability to send and receive HTTP packetsCapability to send and receive HTTP packets Capability to process XML [ Requires an XML Capability to process XML [ Requires an XML

parser ]parser ]

Built on open technologiesBuilt on open technologies Facilitates true distributed interoperability Facilitates true distributed interoperability No firewall restrictionsNo firewall restrictions

Page 12: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

12

Disadvantages of SOAPDisadvantages of SOAP Based on HTTP, and is therefore Based on HTTP, and is therefore

StatelessStateless Based on a request/response architecture – Implies no Based on a request/response architecture – Implies no

callback functionalitycallback functionality

Performance is slightly degraded for the following Performance is slightly degraded for the following reasons: reasons:

An XML processor needs to be loaded each time to parse a SOAP request/response

The SOAP request/response has to be parsed to extract the required information

Currently supports only parameter serialization by value

Will require XML processors that support full schema parsing, if XML schema extensions are used to format SOAP messages

Page 13: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

13

The Microsoft Visual Studio SOAP The Microsoft Visual Studio SOAP Toolkit – What is it?Toolkit – What is it?

A technology preview Microsoft’s first step in demonstrating its

commitment to supporting SOAP functionality in its development tools

Includes components that can be used to implement SOAP messaging/functionality in Visual Studio applications:

Expose functionality implemented in COM components as Web Services

Access Web Services using SOAP messaging

Microsoft’s SOAP based distributed object infrastructure – COM (Component Technology) + SOAP (Wire Protocol)

Page 14: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

14

The Microsoft Visual Studio SOAP The Microsoft Visual Studio SOAP Toolkit – What does it include?Toolkit – What does it include?

An SDL Generator: Used to generate XML based Service Descriptions for Web Services

ROPE [ Remote Object Proxy Engine ]: A COM DLL which exposes objects that provide the infrastructure for binding SOAP clients and servers

Sample Applications

Online Documentation

Page 15: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

15

SOAP Toolkit TerminologySOAP Toolkit Terminology

Web ServiceWeb Service Service description languageService description language Web Services DiscoveryWeb Services Discovery SOAP ListenerSOAP Listener ROPEROPE The SOAP Toolkit SDL WizardThe SOAP Toolkit SDL Wizard

Page 16: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

16

Key SOAP Toolkit TechnologiesKey SOAP Toolkit Technologies COMCOM XMLXML

Writing well-formed XML, schemas, and Writing well-formed XML, schemas, and namespacesnamespaces

HTTP HTTP HTTP GET and POSTHTTP GET and POST

IISIIS Setting up virtual directoriesSetting up virtual directories IIS securityIIS security Directory permissionsDirectory permissions

ASP/ISAPIASP/ISAPI Visual Studio development toolsVisual Studio development tools

Page 17: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

17

ROPE – Remote Object Proxy EngineROPE – Remote Object Proxy Engine A COM DLL [ ROPE.DLL ] Implements programmable objects that provide

infrastructural services to bind SOAP clients and servers:

Generating SOAP Request Payloads Generating SOAP Response Payloads Transporting the SOAP Requests and Responses using

HTTP Interpreting Request payloads to extract method

invocation information Interpreting Response payloads to extract results returned

to the client

Advantages of using ROPE

Page 18: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

18

The ROPE ObjectsThe ROPE Objects ROPE.ProxyROPE.Proxy

Provides a high-level interface that enables client Provides a high-level interface that enables client applications to access remote Web Services exposed using applications to access remote Web Services exposed using the SOAP protocol as if they were local COM objects the SOAP protocol as if they were local COM objects

ROPE.SOAPPackagerROPE.SOAPPackager Sending and receiving SOAP requests and responsesSending and receiving SOAP requests and responses Functionality for accessing contents of a SOAP envelopeFunctionality for accessing contents of a SOAP envelope

ROPE.WireTransferROPE.WireTransfer Functionality for executing HTTP POST and GETFunctionality for executing HTTP POST and GET

ROPE.SDMethodInfoROPE.SDMethodInfo Provides Information about methods exposed by a Web Provides Information about methods exposed by a Web

ServiceService

Page 19: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

19

The ROPE ObjectsThe ROPE Objects (2) (2)

ROPE.SDParameterInfoROPE.SDParameterInfo Describes the parameters for a method described Describes the parameters for a method described

by an SDMethodInfo objectby an SDMethodInfo object

ROPE.SDEndPointInfoROPE.SDEndPointInfo Describes the URI location of a Web ServiceDescribes the URI location of a Web Service

ROPE.ServiceDescriptorsROPE.ServiceDescriptors A collection of SDMethodInfo and A collection of SDMethodInfo and

SDEndPointInfo objectsSDEndPointInfo objects

Page 20: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

20

Lab 1: Installing the Visual Studio Lab 1: Installing the Visual Studio SOAP ToolkitSOAP Toolkit

Instructions on downloading and installing Instructions on downloading and installing the SOAP Toolkitthe SOAP Toolkit

Exploring the SOAP Toolkit download – What Exploring the SOAP Toolkit download – What does it contain? does it contain?

Exploring the SOAP Toolkit documentationExploring the SOAP Toolkit documentation

Page 21: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

21

Setting UP a VB 6.0 Web ServiceSetting UP a VB 6.0 Web Service

Create the VB COM DLL whose methods you wish Create the VB COM DLL whose methods you wish to expose as Web Services – Stateless methods, to expose as Web Services – Stateless methods, parameters should be passed by valueparameters should be passed by value

Register the component on the Web server Register the component on the Web server Grant the IIS account(s) NTFS ‘Read & Execute’ Grant the IIS account(s) NTFS ‘Read & Execute’

access permissions to the componentaccess permissions to the component Use the SOAP Toolkit SDL Generation Wizard to Use the SOAP Toolkit SDL Generation Wizard to

generate the SDL and the ASP interface for the generate the SDL and the ASP interface for the service; specify an HTTP-accessible IIS virtual service; specify an HTTP-accessible IIS virtual directory as the location to store the generated filesdirectory as the location to store the generated files

Place the generic ASP Listener in the IIS virtual Place the generic ASP Listener in the IIS virtual directory that contains the SDL and ASP Interface directory that contains the SDL and ASP Interface for the Web Servicefor the Web Service

Page 22: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

22

SDL Generation Wizard – Screen 1 of 6SDL Generation Wizard – Screen 1 of 6

Page 23: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

23

SDL Generation Wizard – Screen 2 of 6SDL Generation Wizard – Screen 2 of 6

Page 24: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

24

SDL Generation Wizard – Screen 3 of 6SDL Generation Wizard – Screen 3 of 6

Page 25: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

25

SDL Generation Wizard – Screen 4 of 6SDL Generation Wizard – Screen 4 of 6

Page 26: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

26

SDL Generation Wizard – Screen 5 of 6SDL Generation Wizard – Screen 5 of 6

Page 27: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

27

SDL Generation Wizard – Screen 6 of 6SDL Generation Wizard – Screen 6 of 6

Page 28: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

28

Lab 2: Setting Up the PRODUCTS Lab 2: Setting Up the PRODUCTS Web ServiceWeb Service

Developing the PRODINFO COM DLL Developing the PRODINFO COM DLL Implementing the PRODUCTS class moduleImplementing the PRODUCTS class module Methods: GetProducts(), GetUnitsInStock(ByVal Methods: GetProducts(), GetUnitsInStock(ByVal

ProductName as String)ProductName as String)

Setting up the Web ServiceSetting up the Web Service Examining the SDLExamining the SDL Examining the ASP interface fileExamining the ASP interface file

Page 29: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

29

Accessing the Web ServiceAccessing the Web Service

The three server components that expose a The three server components that expose a SOAP Toolkit Web ServiceSOAP Toolkit Web Service

SDL document [generated by the wizard]SDL document [generated by the wizard] ASP/ISAPI interface [generated by the wizard]ASP/ISAPI interface [generated by the wizard] SOAP Toolkit Listener SOAP Toolkit Listener

Client components required to access a Client components required to access a SOAP Web ServiceSOAP Web Service Rope.dll – Copy and register on the client Rope.dll – Copy and register on the client

workstationworkstation ROPE client – A Visual Studio/ASP application ROPE client – A Visual Studio/ASP application

that utilizes the ROPE objects to access a Web that utilizes the ROPE objects to access a Web ServiceService

Page 30: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

30

Server ComponentsServer Components

What does the SDL document contain?What does the SDL document contain? Interface files – What are they?Interface files – What are they? What is a SOAP Listener?What is a SOAP Listener? Types of VS SOAP Toolkit Listeners – ASP Types of VS SOAP Toolkit Listeners – ASP

and ISAPIand ISAPI Where are the generic Listeners located?Where are the generic Listeners located?

ASP: <ASP: <drivedrive>:\Program Files\SOAP_Toolkit\>:\Program Files\SOAP_Toolkit\ASP_Listener [Listener.ASP]ASP_Listener [Listener.ASP]

ISAPI: <ISAPI: <drivedrive>:\Program Files\SOAP_Toolkit\>:\Program Files\SOAP_Toolkit\ISAPI_Listener [soapisapi.dll]ISAPI_Listener [soapisapi.dll]

What does the generic ASP Listener do? How What does the generic ASP Listener do? How does it work with the ASP interface file?does it work with the ASP interface file?

Page 31: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

31

Examining the Key Sections of a Sample Examining the Key Sections of a Sample SDLSDL The SDL specifies the URL of the Web Service’s ASP interface fileThe SDL specifies the URL of the Web Service’s ASP interface file

<service><service>

<addresses><addresses>

<address uri='http://karravms-srv2/soap/Products.asp'/><address uri='http://karravms-srv2/soap/Products.asp'/>

</addresses></addresses>

<implements name='Products'/><implements name='Products'/>

</service></service> It contains XML-based specifications of the methods exposed by the Web It contains XML-based specifications of the methods exposed by the Web

ServiceService<element name='GetUnitsInStock'><element name='GetUnitsInStock'>

<type><type>

<element name='ProductName' type='dt:string'/><element name='ProductName' type='dt:string'/>

</type></type>

</element></element>

<element name='GetUnitsInStockResponse'><element name='GetUnitsInStockResponse'>

<type><type>

<element name='return' type='dt:short'/><element name='return' type='dt:short'/>

</type></type>

</element></element>

Page 32: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

32

Examining an ASP Interface FileExamining an ASP Interface File<%@ Language=VBScript %><% Option ExplicitResponse.Expires = 0

'URI of service description fileConst SOAP_SDLURI = http://karravms-srv2/soap/Products.xml%><!--#include file="listener.asp"-->

<%Public Function GetProducts ()

Dim objGetProductsSet objGetProducts = Server.CreateObject("ProdInfo.Products")GetProducts = GetXMLFromADORS(objGetProducts.GetProducts())'Insert additional code hereSet objGetProducts = NOTHING

End Function

Public Function GetUnitsInStock (ByVal ProductName)Dim objGetUnitsInStockSet objGetUnitsInStock = Server.CreateObject("ProdInfo.Products")

GetUnitsInStock = objGetUnitsInStock.GetUnitsInStock(ProductName)'Insert additional code here

Set objGetUnitsInStock = NOTHINGEnd Function%>

Page 33: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

33

SDL

ROPE

WEB SERVICES PROVIDER

COMObject

ASP Interface

ASP Listener

Anatomy of a SOAP Web Services Anatomy of a SOAP Web Services ProviderProvider

Page 34: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

34

SDL

Your ClientCode

ROPE PROXY

Anatomy of a ROPE Client Anatomy of a ROPE Client

Page 35: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

35

SOAP Toolkit Client/Server CommunicationSOAP Toolkit Client/Server Communication

SDLs

ROPE

WEB SERVICES PROVIDER

COMObject

SDL

ClientCode

ROPE PROXY

ROPE Client

ASP Interface

ASPListener

SOAPRequest/ResponsePayloads

Page 36: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

36

Accessing a Web Service using a ROPE Client Accessing a Web Service using a ROPE Client Using the ROPE.Proxy ObjectUsing the ROPE.Proxy Object

The ROPE.Proxy Object – What is it?The ROPE.Proxy Object – What is it? The LoadServicesDescription() method of the ROPE.Proxy

Object: LoadServicesDescription icURI, “<URL To the Web Service’s SDL>” LoadServicesDescription icSTRING, “<XML String representation of

the Web Service’s SDL>”

Important properties of the ROPE.Proxy object ServicesDescription DataSent DataReceived FaultCode, FaultString, FaultDetail

ROPE.Proxy object uses the ROPE.SoapPackager and the ROPE.WireTransfer objects

Page 37: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

37

Using ROPE.Proxy to Access a Web Using ROPE.Proxy to Access a Web Service: Code WalkthroughService: Code WalkthroughDim rproxy As ROPE.ProxyDim rproxy As ROPE.Proxy

Dim units As IntegerDim units As Integer

Dim SelItem As StringDim SelItem As String

Set rproxy = New ROPE.ProxySet rproxy = New ROPE.Proxy

rproxy.LoadServicesDescription icURI, rproxy.LoadServicesDescription icURI, "http://karravms-srv2/soap/Products.xml""http://karravms-srv2/soap/Products.xml"

If lstProducts.Text <> "" ThenIf lstProducts.Text <> "" Then

SelItem = lstProducts.TextSelItem = lstProducts.Text

txtUnits.Text = rproxy.GetUnitsInStock(SelItem)txtUnits.Text = rproxy.GetUnitsInStock(SelItem)

End IfEnd If

Set rproxy = NothingSet rproxy = Nothing

Lab 3: Using the ROPE.Proxy Object to access the Lab 3: Using the ROPE.Proxy Object to access the

PRODINFO.PRODUCTS Web ServicePRODINFO.PRODUCTS Web Service

Page 38: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

38

The ROPE.SoapPackager and The ROPE.SoapPackager and ROPE.WireTransfer ObjectsROPE.WireTransfer Objects

ROPE.SOAPPackagerROPE.SOAPPackager Sending and receiving SOAP requests and responsesSending and receiving SOAP requests and responses Access contents of a SOAP envelopeAccess contents of a SOAP envelope

ROPE.WireTransferROPE.WireTransfer Execute HTTP POST and GETExecute HTTP POST and GET

The ROPE.Proxy object uses these two objects to send and The ROPE.Proxy object uses these two objects to send and receive SOAP requests and responsesreceive SOAP requests and responses

Important methods of the ROPE.SOAPPackager object:Important methods of the ROPE.SOAPPackager object: LoadServicesDescription, GetMethodStruct, GetParameter, LoadServicesDescription, GetMethodStruct, GetParameter,

SetParameter, SetPayloadDataSetParameter, SetPayloadData Important methods/properties of the ROPE.WireTransfer object Important methods/properties of the ROPE.WireTransfer object

Methods: AddStdSOAPHeaders, PostDataToURIMethods: AddStdSOAPHeaders, PostDataToURI Properties: DataSent, DataReceivedProperties: DataSent, DataReceived

Page 39: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

39

Using the ROPE.SOAPPackager and Using the ROPE.SOAPPackager and ROPE.WireTransfer Objects to Access a ROPE.WireTransfer Objects to Access a Web ServiceWeb Service

Lab 4: Using the ROPE.SoapPackager and Lab 4: Using the ROPE.SoapPackager and ROPE.WireTransfer objects to access the ROPE.WireTransfer objects to access the PRODUCTS Web ServicePRODUCTS Web Service

SOAP payloads revisitedSOAP payloads revisited Request and response SOAP payloadsRequest and response SOAP payloads HTTP requests and responsesHTTP requests and responses XML parsersXML parsers

Lab 5: Examining the SOAP and HTTP Lab 5: Examining the SOAP and HTTP request and response payloads generated by request and response payloads generated by the ROPE.WireTransfer objectthe ROPE.WireTransfer object

Page 40: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

40

Web Services DiscoveryWeb Services Discovery

Concept of Web Services DiscoveryConcept of Web Services Discovery Need for a Web Services Discovery LanguageNeed for a Web Services Discovery Language ROPE objects that aid in Web Services Discovery:ROPE objects that aid in Web Services Discovery:

ROPE.SDMethodInfo: Provides Information about methods ROPE.SDMethodInfo: Provides Information about methods exposed by a Web Serviceexposed by a Web Service

ROPE.SDParameterInfo: Describes the parameters for a ROPE.SDParameterInfo: Describes the parameters for a method described by a SDMethodInfo objectmethod described by a SDMethodInfo object

ROPE.SDEndPointInfo: Describes the URI location of a Web ROPE.SDEndPointInfo: Describes the URI location of a Web ServiceService

ROPE.ServiceDescriptors: A collection of SDMethodInfo ROPE.ServiceDescriptors: A collection of SDMethodInfo and SDEndPointInfo objectsand SDEndPointInfo objects

Lab 6: Implementing a simple Web Services Lab 6: Implementing a simple Web Services Discovery Client using the ROPE ServiceDescriptors, Discovery Client using the ROPE ServiceDescriptors, SDMethodInfo, and SDParameterInfo objectsSDMethodInfo, and SDParameterInfo objects

Page 41: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

41

SOAP ToolkitSOAP Toolkit Data TypesData Types

Currently only scalar atomic data types are Currently only scalar atomic data types are supported: supported: String, Integer, Double, Short, Float, Boolean, and Byte

Methods returning composite data types like ADO Recordsets and Arrays require: Manual modifications must be made to the SDL file to describe the

composite data type – XML Schemas must be used to describe the composite type

Additional wrapper code must be added to the ASP Interface to transform the return value into a form that can be packaged into a supported data type [ usually a String ]

Custom code in the SOAP client to parse the return value and extract the required data

Lab 7: Handling ADO Recordsets: Accessing the GetProducts() method of the PRODUCTS Web Service

Page 42: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

42

Handling ADO Recordsets: Modifying the Handling ADO Recordsets: Modifying the ASP Interface FileASP Interface File

Public Function GetProducts ()Dim objGetProductsSet objGetProducts = Server.CreateObject("ProdInfo.Products")

GetProducts = GetXMLFromADORS(objGetProducts.GetProducts())'Insert additional code here

Set objGetProducts = NOTHINGEnd Function

What does the function GetXMLFromADORS do? Transforms the data in the ADO Recordset to a well formed

XML String Calls the CDataIt() custom function to enclose the XML

string within a CDATA section

Page 43: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

43

Handling ADO Recordsets: Modifying the Handling ADO Recordsets: Modifying the SDL FileSDL File

<element name='GetProductsResponse'> <type> <element name='PRODUCT' type='ProductStruct'/> </type> </element> <element name='ProductStruct'> <type> <element name='ProductID' type='dt:string'/> <element name='ProductName' type='dt:string'/> </type> </element>

Page 44: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

44

Handling ADO Recordsets: Parsing the Returned XML Handling ADO Recordsets: Parsing the Returned XML String in the SOAP ClientString in the SOAP Client

Dim opxy As ROPE.ProxyDim result As StringDim ResultXML As MSXML2.DOMDocument26Dim rs As ADODB.Recordset

Set opxy = New ROPE.Proxyopxy.LoadServicesDescription icURI, "http://karravms-srv2/soap/Products.xml"

result = opxy.GetProducts()

Set ResultXML = New MSXML2.DOMDocument30ResultXML.setProperty "SelectionLanguage", "XPath"ResultXML.loadXML result

Dim ProductList As MSXML2.IXMLDOMNodeListDim Product As MSXML2.IXMLDOMNode

Set ProductList = ResultXML.selectNodes("//ProductName")For Each Product In ProductList lstProducts.AddItem Product.TextNext

Set opxy = Nothing

Page 45: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

45

XML Myths and FactsXML Myths and Facts MythsMyths

XML is a great languageXML is a great language It is the panacea for all problems encountered in It is the panacea for all problems encountered in

current programming languages and toolscurrent programming languages and tools SOAP is a good example of applying XML to SOAP is a good example of applying XML to

address a real-world development requirementaddress a real-world development requirement

FactsFacts XML is a great markup language for exchanging XML is a great markup language for exchanging

datadata It is not a replacement for any application It is not a replacement for any application

development tool or component technologydevelopment tool or component technology SOAP is a great example of applying XML to SOAP is a great example of applying XML to

address a real-world development requirementaddress a real-world development requirement

Page 46: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web

46

Additional ReadingAdditional Reading

Online documentation: Online documentation: The ROPE Samples TutorialThe ROPE Samples Tutorial Guide to using the SOAP Toolkit WizardGuide to using the SOAP Toolkit Wizard Troubleshooting the SOAP ToolkitTroubleshooting the SOAP Toolkit

Returning ADO Recordsets with SOAP Returning ADO Recordsets with SOAP Messaging Messaging http://msdn.microsoft.com/xml/articles/soapghttp://msdn.microsoft.com/xml/articles/soapguide_ado.aspuide_ado.asp

Understanding SOAPUnderstanding SOAP by Kennard Scribner by Kennard Scribner ISBN: 0-672-31922-5 Publisher: SAMSISBN: 0-672-31922-5 Publisher: SAMS

NOTE: The above link is one path; it has been wrapped for readability.NOTE: The above link is one path; it has been wrapped for readability.

Page 47: Implementing and Accessing Web Services Using Visual Basic 6.0 and the Visual Studio SOAP Toolkit Karthik Ravindran Developer Support Engineer VB/ASP Web