Technical Notes |
|
Verastream Host Integrator version 6.5 Web Builder cannot directly generate a Visual Basic (VB) .NET Web Service. This technical note demonstrates how you can create a VB .NET Web Service by generating and converting a C# Web Service.
The example presented in this document includes three basic steps:
For information on creating Web services, see the Host Integrator help topic, Building Web Builder Projects.
A web browser should open with your Hello World Web service.
While the C# and VB languages are similar, VB is more verbose. You can make the conversion manually, but several conversion tools are available on the Internet.
This example uses a web-based tool, Convert VB.NET to C# (available from http://www.kamalpatel.net/ConvertCSharp2VB.aspx).
Do not use Dev Studio at this point because it attempts to auto-format the C# code, which causes errors.
The conversion tool does not handle comment blocks well. You can add them back into the code when the conversion is complete.
/// <summary>/// Some stuff/// </summary>For example:
public DataSet ExecuteSQLStatement(string SQL, int MaxRows) should read
public DataSet ExecuteSQLStatement(string SQL, int MaxRows) Verify that the InsertNewAccount signature has all the parameters on the same line.
Note: Specific instructions regarding the use of the tool will not apply if you are using a different tool or are making the conversion manually.
You will work with this generated (modified) code, which appears in the bottom portion of the window. There should be no reported errors in the code comments (in the upper section).
Note: You must continue editing because the tool does not handle large sections of code. You can use smaller code sections and re-run the tool using just a single C# method, and then copy the results into the section containing the modified code.
<WebService(Namespace:="http://yourcompany.com")> _<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _Paste it into your Sample1Service file below the ConnectMethods enumeration and just above the Sample1Service class definition.
x<%@ WebService Language="vb" CodeBehind="~/App_Code/Service.vb" Class="Service" %> to
<%@ WebService Language="vb" CodeBehind="~/App_Code/Sample1Service.vb" Class="Sample1.Sample1Service" %>The conversion tool may leave some additional changes between C# and VB, which need to be addressed. They are included below in order of listed errors.
#region Component Designer generated code …#endregionto
#Region "Component Designer generated code" ...#End RegionIf(disposing && components != null){ …}to
If disposing And components Is Nothing Then …End IfC# logical statements equate to:
&& = And
|| = Or etc.
!= equates to <>
!variable = Not Variable
Visually scan the code to make sure it is logically doing the same thing.
Note: When making the conversion, the C# Switch statement was converted oddly. You may need to remove the Exit Subs that were introduced.
Switch(condition){ case constant: … break;}to
Select Case condition Case constant … Case constant …End SelectYou should now be able to build and execute the web service.
These completed examples are available in the Download Library:
Sample1Service.vb.finished.txt