I'm playing at trying to get a web service to work following a tutorial.
So I have a solution with two projects - one a web service the other a windows app.
The web service 'runs' okay. This is the code for the web service:
I'm trying now to call the web service from the windows app. I have a form with a text box and button on it. I have also added a web reference - this opened a window where I could 'select web services in this solution' - it found 'Service1' (which is the class name above) and named the reference 'fred'. This is the code for the form.Code:using System; using System.Data; using System.Web; using System.Collections; using System.Web.Services; using System.Web.Services.Protocols; using System.ComponentModel; namespace WebService1 { /// <summary> /// Summary description for Service1 /// </summary> [WebService(Namespace = "http://localhost/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [ToolboxItem(false)] public class Service1 : System.Web.Services.WebService { [WebMethod] public DateTime GetServerTime() { return DateTime.Now; } } }
When I typed the line in red above - after I had typed WebDemoClient (which is the namespace of the windows app project) when I typed the full stop intellisense displayed the choices ofCode:using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using WebDemoClient.fred; namespace WebDemoClient { public partial class WebDemoClient : Form { public WebDemoClient() { InitializeComponent(); } private void cmdServerTime_Click(object sender, EventArgs e) { fred oService = new fred(); this.txtServerTime.Text = oService.GetServerTime().ToString(); this.txtServerTime.Text = fred.GetServerTime().ToString(); } } }
{}fred
{}properties
... so I guess it knows what fred is.
However when I try to build it, it falls over on the line in blue. It says
WebDemoClient.fred is a 'namespace' but is used like a 'type'
What am I doing wrong. It seems the form can 'see' the web service but I am not referencing it properly.
Thanks for any help.




Reply With Quote