Intro | Search taxa | Taxon tree | Sources | Webservice | Statistics | Editors | Log in

Calling the RAS webservice from Visual Basic .NET 2010

This tutorial assumes you have installed Micosoft Visual Basic .NET 2010.

Step 1: Start a new Windows Forms Application project
Name it 'RASReferenceExample'
Then click Project from the top Menu
Select Add Service Reference...
In the Address box add '', then click Go
The AphiaNameService should appear and if you expand the list you will see 'AphiaNameServicePortType'

Step 2: make a button
In the Namespace box select a suitable name
Add a button to your project from the Toolbox and name it btnQueryTaxa
Add a list box from the Toolbox add it to your form and name it lstRecords
Double click on the button to access its click event
Adjust your projects Form code to look like the following code
Imports RASReferenceExample.RASReference
Public Class Form1
    Private Sub btnQueryTaxa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnQueryTaxa.Click
        'Declare dimensions
        Dim i As Integer, objRASTool As New AphiaNameServicePortTypeClient, objRecords() As AphiaRecord, strUserInput As String
        'Get users input of a string
        strUserInput = Trim(InputBox("Please enter a taxa to Query", "RAS Query"))
        'Use the users input to get the possible records from the RAS website
        objRecords = objRASTool.getAphiaRecords(strUserInput, True, True, True, 1)
        'clear the listbox prior to filling it
        'loop through retrieved records and
        For i = 0 To objRecords.GetUpperBound(0)
        'inform the user that the query is complete
        MsgBox("Query Completed Successfully with " & objRecords.GetUpperBound(0) + 1 & "Records Retrieved", MsgBoxStyle.OkOnly, "RAS Query")

    End Sub
End Class

Note if your project will be connecting to the internet via a proxy server please add the following lines of code to the app.config file after the section
    <servicePointManager expect100Continue="false"/>
  <defaultProxy useDefaultCredentials="true"></defaultProxy>

Download this example.
Download an example without having to rely on the settings in the App.Config file

Credits for this tutorial go to Michael Thompson (Gardline Environmental, UK) & Jeroen Steenbeek (University of British Columbia, Canada)

This service is powered by LifeWatch Belgium
Learn more»
Website and databases developed and hosted by VLIZ · Page generated 2024-07-14 · contact: Anton Van de Putte