Attachmate Worldwide  |   Contact Us  |   NetIQ.com
Home » Support » Solution Library

Technical Notes

Creating a Host Integrator Visual Basic .NET Web Service
Technical Note 10211
Last Reviewed 23-Feb-2007
Applies To
Verastream Host Integrator version 6.5
Summary

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:

  • Generating the C# Web Service using Web Builder.
  • Creating a new VB.NET Web Service.
  • Converting the Web Builder generated C# source.

Generate the C# Web Service using Web Builder

  1. Create a new .NET 2.0 Web Service, and name it Sample1.

For information on creating Web services, see the Host Integrator help topic, Building Web Builder Projects.

  1. Use the Host Integrator model, CICSAcctsDemo, to build the project.
  2. Verify that the test web page loads and close Web Builder.

Create a New VB.NET Web Service from Visual Studio 2005

  1. In Visual Studio, open New Web Site.
  2. Click ASP .NET Web Service.
  3. Change the language option from C# to VB and name it VBWebSite1. Click OK.
  4. Edit the created file Service.vb and change the Namespace at the top from http://tempuri.org to http://<yourcompany>.com.
  5. Add the WRQ.Verastream.HostIntegrator.dll to your project:
    1. Select Website > Add Reference. Select the Browse tab.
    2. Select the WRQ.Verastream.HostIntegrator.dll from the <install_directory>\VHI\lib\dotnet subdirectory. Click OK.
  6. Build your project:
    1. In Verastream, choose Build > Build Web Site; then choose Debug > Start Debugging.
    2. Select Run without Debugging because debugging is not enabled in the project.

A web browser should open with your Hello World Web service.

Convert the Web Builder Generated C# Source

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).

  1. Using the generated Web Builder source code, from <inetpub>\wwwroot\Sample1\App_code, open a copy of Sample1.asmx.cs from in a text editor.

Do not use Dev Studio at this point because it attempts to auto-format the C# code, which causes errors.

  1. Groom the source code:
    1. Remove all the comment blocks.

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>
    1. Verify that the method signatures are all on the same line.

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.

  1. Open Convert VB.NET to C# or another conversion tool.

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.

  1. Copy the groomed contents of the source code from Sample1.asmx.cs into the conversion tool.
  2. Click Generate VB.NET Code.

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.

  1. In the conversion tool, open the VBWebSite1 Dev Studio project.
  2. Add a new class to the VBWebSite1Project named Sample1Service.
    1. From the Solution Explorer, select App Code. Right-click and choose Add New Item.
    2. From the Add New Item dialog, select Class.
    3. Type Sample1Service in the Name field; click Add to add the new class.
  3. Open the new class Sample1Service in the Dev Studio editor.
  4. Copy the contents of the generated code from the Web browser to your new Sample1Service class replacing the existing Sample1Service code.
  5. From your Dev Studio project's Service.vb, copy:
<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.

  1. Edit your Dev Studio project file Service.asmx by changing the line from:
x<%@ WebService Language="vb" CodeBehind="~/App_Code/Service.vb" Class="Service" %>

to

<%@ WebService Language="vb" CodeBehind="~/App_Code/Sample1Service.vb" Class="Sample1.Sample1Service" %>
  1. Compile the project. Expect errors.

Additional Modifications

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.

  • Convert the designer region comments from:
#region Component Designer generated code

#endregion

to

#Region "Component Designer generated code"
...
#End Region

  • Convert logical IF statements from
If(disposing && components != null)
{

}

to

If disposing And components Is Nothing Then

End If

C# 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.


  • Convert all switch statements into Select statements:
Switch(condition)
{
case constant:

break;
}

to

Select Case condition
Case constant

Case constant

End Select

Build and Execute

You should now be able to build and execute the web service.

Completed Examples

These completed examples are available in the Download Library:

Sample1Service.vb.finished.txt

Service.asmx.finished.txt

Related Technical Notes
40999 Verastream Host Integrator Technical Notes

Did this technical note answer your question?

Yes    No    Somewhat     Not sure yet

Additional comments about this tech note:

Need further help? For technical support, please contact Support.