C# for Microsoft .NET Snippet

This code snippet references the ABAService Web Service only.
To reference the ABAExpress Web Service, in the Web References Section of your project, change the Web Reference URL value to https://www.lyonsreg.com/webservices/abaexpress/ABAService.asmx?wsdl.

		// Called when user clicks go button - call the web service.
		private void btnGo_Click(object sender, System.EventArgs e)
		{
			// abaService class automatically generated from WSDL
			// and located in WebReferences section
			abaService.ABAService service;
			try
			{
				// Hour Glass.
				this.Cursor = Cursors.WaitCursor;
				// Create the service.
				service = new abaService.ABAService();

				// Get the company ID.x
				// Logon
				string token = service.Logon(int.Parse(tbCompanyID.Text), tbUserName.Text.Trim(), tbPassword.Text.Trim());
				// Get the banks XML.
				string xml = service.GetBanksXML(token, tbABA.Text);
				if (xml != "")
					ProcessXML(xml);
				
			}
			catch (Exception)
			{
				// Something failed.
				MessageBox.Show("Call to web service failed!", "Error!");
				comboBanks.Items.Clear();
			}
			finally
			{
				// Restore the cursor.
				this.Cursor = Cursors.Default;
			}
		}

		//
		// Process the XML
		//
		private void ProcessXML(string xml)
		{
			try
			{
				comboBanks.Items.Clear();
				XmlDocument xmlDoc = new XmlDocument();
				xmlDoc.LoadXml(xml);
				XmlNodeList nodeList = xmlDoc.SelectNodes("//InstitutionName[@type='M']");
				foreach (XmlNode node in nodeList)
				{
					comboBanks.Items.Add(node.InnerText);
				}
				comboBanks.Enabled = true;
				comboBanks.SelectedIndex = 0;
				btnClear.Enabled = true;
			}
			catch (Exception)
			{
			}
		}
Sample Application
To download a sample CSharp application project, click one of the links below: Other Sample Code Snippets
Complete source code for the above sample applications and other platform variations is available upon request.  Contact us for more information.
© 2012 Lyons Commercial Data. All rights reserved                                                 Home | Developer Area | Glossary | Contact Us | Privacy | Site Map