1

Re: Using Web Services from Visual Studio 2005 and .NET 2

I have successfully used the wsdl importer in VS2005 to import the main wsdl for the web services and it works fine for retrieving single species datasets at least.

However, I'm not able to search for a taxon name and get a list of taxa back (like the java example here: http://212.219.37.104/NBNWebServices/examples/toSource.jsp?fname=ws-taxonomySearchResults.jsp). I've tried importing the taxonomy wsdl file, but it doesnt seem to import the SetSpeciesName method which is essential to search for a taxa. I can't see the definition for SetSpeciesName in the WSDL - am I doing something wrong? Probably.

Cheers,
Andrew

2

Re: Using Web Services from Visual Studio 2005 and .NET 2

I have sorted out the problem with the Taxon search web service from .Net 2005, after much head scratching. Here is some sample code on a button click event:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim pGatewayWebService As GatewayWebService = New GatewayWebService()
        Dim pTaxonomySearchRequest As TaxonomySearchRequest = New TaxonomySearchRequest()
        pTaxonomySearchRequest.ItemElementName = ItemChoiceType.SpeciesName
        pTaxonomySearchRequest.Item = "arvense"
        Dim pTaxon() As Object = pGatewayWebService.GetTaxonomySearch(pTaxonomySearchRequest)
    End Sub

However, this wont work without any changes to the proxy class the VB automatically creates. The automatically generated class will not deserialise the XML into an object properly unless you remove the following attribute from the class declaration:

    <System.CodeDom.Compiler.GeneratedCodeAttribute("System.Web.Services", "2.0.50727.42"), _
     System.Diagnostics.DebuggerStepThroughAttribute(), _
     System.ComponentModel.DesignerCategoryAttribute("code"), _
     System.Web.Services.WebServiceBindingAttribute(Name:="NBNTaxonomySoapBinding", [Namespace]:="http://webservices.searchnbn.net/taxonomyService"), _
     System.Xml.Serialization.XmlIncludeAttribute(GetType(Taxon()))> _
    Partial Public Class GatewayWebService

Because this proxy class is automatically generated, you will need to make the edits again if you recreate it, or you could probably put the code in a Partial Class.

Cheers,
Andrew