tookerello22 0 Newbie Poster

hi how can i view the the web service result in my client app?
the web service is:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Xml;

public struct SecurityInfo
{
    public string location;
    public string areacode;
}
[WebService(Namespace = "http://192.168.1.6/WebService/Service.asmx",
Description = "A Simple Web Calculator Service",
Name = "CalculatorWebService")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

public class Service : System.Web.Services.WebService
{
    private SecurityInfo Security;

    public Service()
    {
        Security.location = "";
        Security.areacode = "";
    }
    private void AssignValues(string Code)
    {

        Security.location = Code;      

        XmlDocument doc = new XmlDocument();

        doc.Load("G:\\Server\\App_Code\\phoneBook.xml");
        XmlNodeList towns = doc.GetElementsByTagName("town");
        foreach (XmlNode town in towns)
        {
            if (Code.Equals(town.ChildNodes[0].Value))
            {
                string resq = town.ParentNode.Attributes["code"].Value;
                string tmp = ("The area code of " + Code + "    " + "is " + "    " + resq.ToString());
                Security.areacode = tmp;
            }
        }
    }
    [WebMethod(Description = "This method call will get the area code for the given town.", EnableSession = false)]
    public SecurityInfo GetSecurityInfo(string Code)
    {
        AssignValues(Code);
        SecurityInfo SecurityDetails = new SecurityInfo();
        SecurityDetails.location = Security.location;
        SecurityDetails.areacode = Security.areacode;
        return SecurityDetails;
    }
}

and the client app is:

using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SmartDeviceProject2.webser;

namespace SmartDeviceProject2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }       
        private string getResult(string input)
        {
            SmartDeviceProject2.webser.CalculatorWebService myservice = new SmartDeviceProject2.webser.CalculatorWebService();            
            string a = "";
            string result = null;
            result = "AREACODE OF" + input + "IS" + myservice.GetSecurityInfo(a);
            return result;            
        }
        private void button1_Click(object sender, EventArgs e)
        {  
            lstResult.Items.Add(getResult(txtInput.Text).ToString());
        }
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.