Search:
Locator+ Code:
FTPOnline Channels Conferences Resources Hot Topics Partner Sites Magazines About FTP RSS 2.0 Feed

Back to VSLive! Orlando Show Daily Home

email article
printer friendly

Upgrade Legacy Apps to Web Services
Here are some tips to improve your security and performance when you upgrade.
by Federico Zoufaly

VSLive! Orlando, September 19, 2002

Note: Federico Zoufaly presented "Converting Your Source Code for Web Services" at VBITS Orlando, Wednesday, September 18. This tip is from that session.

When upgrading Visual Basic applications to .NET and Web services, you must address some implementation issues. I'll provide some tips to deal with unsolved references in Web services, provide security, and improve performance.

The approach I suggest has two main steps. The first step is to take your Visual Basic 6 application, upgrade it to Visual Basic .NET, and achieve a state of functional equivalence. That is, the first step is to assure that your application behaves the same in .NET. Once you have reached functional equivalence, you can start to work on rearchitecting your application and expose some Web services.

To generate a Web service with Visual Studio .NET, you have to locate the functionality (method) you want to expose and then copy it and all its dependencies to a new Web service project. Although this can sound simple, you must take many technical aspects into account.

Dependencies Resolution
Once you have located and isolated the method you want to expose as a Web service and created the Web service project, you need to move your code to the new project. When you move code, some references to necessary items that were left in the original application appear unbound. There are several ways to deal with this problem.

Reference: In some cases, you can fix the problem simply by adding a reference to a library. In this example, the code needs an additional reference to the ADODB library:

<WebMethod()> _
	Function GetOrders(ByRef CustomerID _
			As String) As String
		Dim cn As Object
		Dim rs As New ADODB.Recordset

Copy: When the code references a module or class in the original application, that component can be directly copied to the new project. You might need to perform this step recursively until you have removed all unbound references.

Wrapper: When you are upgrading a code component that is being accessed from multiple applications, it is preferable to wrap the Web service inside the original component. This way, it is not necessary to modify every application that accesses a function, thus reducing redundancies and simplifying maintenance. In this approach, code of methods that were moved to WebMethods is substituted with calls to the Web services method:

'Non-modified interface procedure on 
'the client
Private Sub frmOrder_Load(ByVal _
	eventSender As System.Object, ByVal _
	eventArgs As System.EventArgs) Handles _
	MyBase.Load
		Dim c As New clsCustomer
		Me.grd.Recordset = StringToRs( _
			c.GetOrders(Customer_ID))
End Sub

'Modified DLL function on the server 
'(wrapper)
Function GetOrders(ByRef CustomerID _
	As String) As String
			Dim ws As New localhost.Service1()
			Return ws.GetOrders(CustomerID)
End Function

'Upgraded WebMethod on the server
<WebMethod()> _
	Function GetOrders(ByRef CustomerID _
		As String) As String
			Dim rs As New ADODB.Recordset
			Dim rsReturn As New ADODB.Recordset

			'WebMethod code
			GetOrders = RsToString(rsReturn)
	End Function
Back to top




Sponsored Links
IBM Rational Webcast: What is your code doing?
Learn how XDE can jumpstart your development efforts.

Learn about Code Sharing and Reuse.
Download our FREE White Paper now.

Code at the Speed of Thought with Developer Express Technologies

Get Crystal Reports 9
And Get Free Software!

Delivering Better Software, Faster for the Microsoft .NET Framework

Sonic Stylus Studio 5.0—XQuery, XML, XSTL
For a FREE evaluation copy, click here

Tools Offer:
Try Microsoft Visual Studio Tools
for the Microsoft Office System, FREE.

Visual Studio .NET
New version 2003

Microsoft Windows Server 2003. Try the new platform.

Need custom e-forms, datagrids and database-connected apps? Free Eval.

Sponsored Whitepapers
Office 2003 Offers Expanded XML Integration

Use .NET and XML to Power New Office Solutions



Java Pro | Visual Studio Magazine | Windows Server System Magazine
.NET Magazine | Enterprise Architect | XML & Web Services Magazine
VSLive! | Thunder Lizard Events | Discussions | Newsletters | FTP Home