1

Re: Any documention For DOT NET

Hi to all
Any documention For DOT NET is avialbale for webservice or any other materail andy one know how to use webservice in dot net

Thanks In advance

2 (edited by Jonathan Cooper 06-02-2007 10:15:04)

Re: Any documention For DOT NET

Oops - I posted this on the wrong thread - I'll copy it over, Jon :D

Hi wasim,

I don't have time to write a c# example for you, however Java is so similar to c# you should be able to work it out from there.  Here is a link to a Java example, in the table take a look at the 'Taxonomy Search' example and source:

http://www.searchnbn.net/library/webser … amples.jsp

You will have to create your dll from the wsdl first since we haven't posted a pre-built one.  The wsdl is found at http://212.219.37.104/NBNWebServices/ws/taxonomy/WSDL

Jon

3

Re: Any documention For DOT NET

Sorry wasim,

my previous reply to you in this thread was intended for your other question about taxonomy searching - I'll post it there instead.  As regards your specific question about using .NET.  Have you downloaded the .dll of proxy classes to use?  If not the you can get it from here: http://www.searchnbn.net/library/webser … tTools.jsp and go to .NET at the bottom.  Or you can build them from the wsdl which is found at http://212.219.37.104/NBNWebServices/ws/WSDL

Here are some example c# methods that should help:

Jon

        private void button1_Click(object sender, System.EventArgs e)
        {
            try
            {
                richTextBox1.Text = "";

                //Create the query
                OneSiteDataRequest osdr = new OneSiteDataRequest();
                
                //Change this depending what query you want to do
                //osdr.GeographicalFilter = getPolyGF();
                osdr.GeographicalFilter = getKnownSiteGF();
                
                //Add other filters if you want (should really be part of the form...)
                osdr.TaxonVersionKey = "MM0001Z1009MWTO1";

                //Get the response
                GatewayWebService gws = new GatewayWebService();
                GatewayData gd = gws.GetSiteData(osdr);
                
                //Add the map image
                Data d = gd.Data;
                insertMap(d.Map.Url.ToString());

                //Add some output
                Species[] ss = d.SpeciesList;
                for(int i=0; i<ss.Length; i++)
                {
                    richTextBox1.Text += ss[i].ScientificName + "\n";
                }

                richTextBox1.Text += "\n\nNumber of species: " + ss.Length;
            }
            catch(Exception ex)
            {
                richTextBox1.Text += "\n\n" + ex.Message;
            }

        }

        private void insertMap(String url)
        {
            HttpWebRequest req = (HttpWebRequest) WebRequest.Create(url);
            req.Method = "GET";
            WebResponse resp = req.GetResponse();
            Stream st = resp.GetResponseStream();
            Bitmap bmp = new Bitmap(Image.FromStream(st));
            pictureBox1.Image = bmp;
        }

        private GeographicalFilter getPolyGF()
        {
            //Create the geographic filter
            Point[] ps = new Point[4];
            Point p1 = new Point();
            Point p2 = new Point();
            Point p3 = new Point();
            Point p4 = new Point();
            p1.srs = SpatialReferenceSystem.osgb_BNG;
            p2.srs = SpatialReferenceSystem.osgb_BNG;
            p3.srs = SpatialReferenceSystem.osgb_BNG;
            p4.srs = SpatialReferenceSystem.osgb_BNG;
            p1.x = 490000;
            p2.x = 490000;
            p3.x = 500000;
            p4.x = 500000;
            p1.y = 430000;
            p2.y = 440000;
            p3.y = 440000;
            p4.y = 430000;
            ps[0] = p1;
            ps[1] = p2;
            ps[2] = p3;
            ps[3] = p4;
            PolygonBoundary b = new PolygonBoundary();
            b.Ring = ps;
            Polygon p = new Polygon();
            p.srs = SpatialReferenceSystem.osgb_BNG;
            p.Boundary = b;
            GeographicalFilter gf = new GeographicalFilter();
            gf.Item = p;
            //Add some map settings
            gf.MapSettings = getMapSettings();
            return gf;
        }

        private GeographicalFilter getKnownSiteGF()
        {
            KnownSite site = new KnownSite();
            site.providerKey = "GA000339";//Monks Wood
            site.siteKey = "1002775";//EN SSSI
            GeographicalFilter gf = new GeographicalFilter();
            gf.Item = site;
            //Add some map settings
            gf.MapSettings = getMapSettings();
            return gf;
        }

        private MapSettings getMapSettings()
        {
            MapSettings ms = new MapSettings();
            ms.outlineColour = "#000000";
            ms.fillTransparency = 0.0;
            ms.fillTransparencySpecified = true;
            return ms;
        }