Entrez PubMed Nucleotide Protein Genome Structure OMIM PMC Journals Books

Using E-Utilities Web Service with Microsoft Visual Basic .NET
Updated: January 18, 2006

SOAP Interface for E-Utilities was tested with:
  - Microsoft Windows XP Professional Version 2002 (Service Pack2)
  - Microsoft .NET Framework 1.1 Version 1.1.4322
  - Microsoft Devel0pment Environment 2003 Version 7.1.3088

Creating an NCBI Web Service Client Project

The following walkthrough describes the process for accessing the NCBI E-Utilities Web service from an application created with Visual Basic.

To create Windows application:

SOAP E-Utilities API

Below is a list of methods we recommend for use with Microsoft Visual Basic.
SOAP interface provides user with two functionally identical sets of methods.
Methods which name ends with _MS are designed for use with Microsoft Visual Studio and SOAP Toolkit 3.0

Click on parameter to get its description.
Click on method name to see the example of use.

  1. Public Function run_eGquery_MS( ByVal term As String, ByVal tool As String, ByVal email As String ) As GQueryResultType
  2. Public Function run_eInfo_MS( ByVal db As String, ByVal tool As String, ByVal email As String ) As eInfoResultType
  3. Public Function run_eLink_MS( ByVal db As String, ByVal id() As String, ByVal reldate As String, ByVal mindate As String, ByVal maxdate As String, ByVal datetype As String, ByVal term As String, ByVal dbfrom As String, ByVal WebEnv As String, ByVal query_key As String, ByVal cmd As String, ByVal tool As String, ByVal email As String ) As eLinkResultType
  4. Public Function run_eSearch_MS( ByVal db As String, ByVal term As String, ByVal WebEnv As String, ByVal query_key As String, ByVal usehistory As String, ByVal tool As String, ByVal email As String, ByVal field As String, ByVal reldate As String, ByVal mindate As String, ByVal maxdate As String, ByVal datetype As String, ByVal retstart As String, ByVal retmax As String, ByVal rettype As String, ByVal sort As String ) As eSearchResultType
  5. Public Function run_eSpell_MS( ByVal db As String, ByVal term As String, ByVal tool As String, ByVal email As String ) As eSpellResultType
  6. Public Function run_eSummary_MS( ByVal db As String, ByVal id As String, ByVal WebEnv As String, ByVal query_key As String, ByVal retstart As String, ByVal retmax As String, ByVal tool As String, ByVal email As String ) As eSummaryResultType
  7. Public Function run_eFetch_MS( ByVal db As String, ByVal id As String, ByVal WebEnv As String, ByVal query_key As String, ByVal tool As String, ByVal email As String, ByVal retstart As String, ByVal retmax As String, ByVal rettype As String, // *rettype for Molecular Biology Databases ByVal strand As String, ByVal seq_start As String, ByVal seq_stop As String, ByVal complexity As String, ByVal report As String ) As eFetchResultType

Examples

Call EGQuery

' run_eGquery_MS provides Entrez database counts for a single search
Try
    Dim serv As New eUtils.eUtilsService
    Dim res As eUtils.GQueryResultType
    ' call NCBI EGQuery utility
    res = serv.run_eGquery_MS("mouse", "", "")
    ' results output
    Label1.Text = "Search term: " + res.Term + Chr(10)
    Label1.Text += "Results: " + Chr(10)
    Dim i As Integer
    For i = 0 To res.eGQueryResult.ResultItem.Length - 1
        Label1.Text += "  " + res.eGQueryResult.ResultItem(i).DbName + _
                       ": " + res.eGQueryResult.ResultItem(i).Count + Chr(10)
    Next i
Catch
    Label1.Text = "Failed"
End Try


Call EInfo

' eInfo utility returns a list of available databases
Try
    Dim serv As New eUtils.eUtilsService
    Dim res As eUtils.eInfoResultType
    ' call NCBI EInfo utility
    res = serv.run_eInfo_MS("", "", "")
    ' results output
    Label1.Text = ""
    Dim i As Integer
    For i = 0 To res.DbList.Items.Length - 1
        Label1.Text += res.DbList.Items(i) + Chr(10)
    Next i
Catch
    Label1.Text = "Failed"
End Try


Call ELink

' example retrieves IDs from Nucleotide for GI 48819,7140345 to Protein
Try
    Dim serv As New eUtils.eUtilsService
    Dim res As eUtils.eLinkResultType
    Dim id(1) As String
    id(0) = "48819,7140345"
    ' call NCBI ELink utility
    res = serv.run_eLink_MS("protein", id, "", "", "", "", "", "nucleotide", "", "", "", "", "")
    ' results output
    Label1.Text = ""
    Dim i As Integer
    For i = 0 To res.LinkSet.Length - 1
        Label1.Text += "Links from " + res.LinkSet(i).DbFrom + " to " + res.LinkSet(i).LinkSetDb(0).DbTo + Chr(10)
        Label1.Text += "  " + res.LinkSet(i).DbFrom + " id(s): "
        Dim k As Integer
        For k = 0 To res.LinkSet(i).IdList.Length - 1
            Label1.Text += res.LinkSet(i).IdList(k).Value + " "
        Next k
        Label1.Text += Chr(10)
        Label1.Text += "  " + res.LinkSet(i).LinkSetDb(0).DbTo + " id(s): "
        For k = 0 To res.LinkSet(i).LinkSetDb(0).Items.Length - 1
            Dim lt As eUtils.LinkType1
            lt = res.LinkSet(i).LinkSetDb(0).Items(k)
            Label1.Text += lt.Id.Value + " "
        Next k
        Label1.Text += Chr(10) + "----------------------" + Chr(10)
    Next i
Catch
    Label1.Text = "Failed"
End Try


Call ESearch

' search in PubMed Central for stem cells in free fulltext articles
Try
    Dim serv As New eUtils.eUtilsService
    Dim res As eUtils.eSearchResultType
    ' call NCBI ESearch utility
    ' NOTE: search term should be URL encoded 
    res = serv.run_eSearch_MS("pmc", "stem+cells+AND+free+fulltext[filter]", "", _
                              "", "", "", "", "", "", "", "", "", "0", "15", "", "")
    ' results output
    Label1.Text = "Original query: stem cells AND free fulltext[filter]" + Chr(10)
    Label1.Text += "Found ids: " + res.Count + Chr(10)
    Label1.Text += "First " + res.RetMax + " ids: "
    Dim i As Integer
    For i = 0 To res.IdList.Length - 1
        Label1.Text += res.IdList(i) + " "
    Next i
Catch
    Label1.Text = "Failed"
End Try


Call ESpell
			
' retrieves spelling suggestions
Try
    Dim serv As New eUtils.eUtilsService
    Dim res As eUtils.eSpellResultType
    ' call NCBI ESpell utility
    res = serv.run_eSpell_MS("pubmed", "mouss", "", "")
    ' results output
    Label1.Text = "Misspelled word: " + res.Query + Chr(10)
    Label1.Text += "Corrected word: " + res.CorrectedQuery
Catch
    Label1.Text = "Failed"
End Try


Call ESummary
			
' retreives document Summaries by list of primary IDs
Try
    Dim serv As New eUtils.eUtilsService
    Dim res As eUtils.eSummaryResultType
    ' call NCBI ESummary utility
    res = serv.run_eSummary_MS("nucleotide", "28864546,28800981", "", "", "", "", "", "")
    ' results output
    Label1.Text = ""
    Dim i As Integer
    For i = 0 To res.DocSum.Length - 1
        Label1.Text += "ID: " + res.DocSum(i).Id + Chr(10)
        Dim k As Integer
        For k = 0 To res.DocSum(i).Item.Length - 1
	  If Not res.DocSum(i).Item(k).Text Is Nothing Then
            Label1.Text += "  " + res.DocSum(i).Item(k).Name + _
                           ": " + res.DocSum(i).Item(k).Text(0) + Chr(10)
          End If
        Next k
        Label1.Text += "-----------------------" + Chr(10) + Chr(10)
    Next i
Catch
    Label1.Text = "Failed"
End Try


Call EFetch
Literature database example

' fetch article from pubmed and displays its abstract
Try
    Dim serv As New eUtils.eUtilsService
    Dim res As eUtils.eFetchResultType
    ' call NCBI EFetch utility
    res = serv.run_eFetch_MS("pubmed", "11748933,11700088", "", "", "", "", "", "", "", "", "", "", "", "")
    ' results output
    Label1.Text = ""
    Dim i As Integer
    For i = 0 To res.PubmedArticleSet.Length - 1
        Label1.Text += "ID: " + res.PubmedArticleSet(i).MedlineCitation.PMID + Chr(10) + "Abstract: " + _
                       res.PubmedArticleSet(i).MedlineCitation.Article.Abstract.AbstractText + Chr(10) + _
                       "--------------------------" + Chr(10) + Chr(10)
    Next i
Catch
    Label1.Text = "Failed"
End Try		

Taxonomy database example

' fetch a record from Taxonomy database
Try
    Dim serv As New eUtils.eUtilsService
    Dim res As eUtils.eFetchResultType
    ' call NCBI EFetch utility
    res = serv.run_eFetch_MS("taxonomy", "9685", "", "", "", "", "", "", "", "", "", "", "", "")
    ' results output
    Label1.Text = res.TaxaSet(0).ScientificName + ": " + _
                  res.TaxaSet(0).Division + " (" + _
                  res.TaxaSet(0).Rank + ")" + Chr(10)
Catch
    Label1.Text = "Failed"
End Try

<< Back

 

 Write to the Help Desk
NCBI | NLM | NIH
Department of Health & Human Services
Privacy Statement | Freedom of Information Act | Disclaimer