Implementing web service issue
-
Hi, I build a web service in .Net. After adding this web service as a web reference in my website and when I am trying to use the methods in a web services by creating the object of it, I am getting only two methods which are equals and reference equals anyone knows why I am facing this issue?
Rock Star
-
Hi, I build a web service in .Net. After adding this web service as a web reference in my website and when I am trying to use the methods in a web services by creating the object of it, I am getting only two methods which are equals and reference equals anyone knows why I am facing this issue?
Rock Star
Well, some code snippets would be nice. It would help us help you :) One possibility without seeing your code is that your web service methods are missing the "WebMethod" attribute: VB.NET
<WebMethod()> \_ Public Function HelloWorld() As String Return "Hello World" End Function
C#
\[WebMethod()\] public string HelloWorld() { return "Hello World"; }
-
Well, some code snippets would be nice. It would help us help you :) One possibility without seeing your code is that your web service methods are missing the "WebMethod" attribute: VB.NET
<WebMethod()> \_ Public Function HelloWorld() As String Return "Hello World" End Function
C#
\[WebMethod()\] public string HelloWorld() { return "Hello World"; }
public class Service1 : System.Web.Services.WebService
{
public DataSet UserDataset = new DataSet();
public SqlDataAdapter UserAdapter = new SqlDataAdapter("Select Query",new SqlConnection("connection string"));\[WebMethod\] public string HelloWorld() { return "Hello World"; } \[WebMethod\] public DataSet GetUserData() { UserAdapter.Fill(UserDataset); return UserDataset; } \[WebMethod\] public DataSet UpdateUserData(DataSet ds) { if(ds != null) { UserAdapter.Update(ds); return ds; } else { return null; } } private void InitializeComponent() { this.UserDataset = new System.Data.DataSet(); ((System.ComponentModel.ISupportInitialize)(this.UserDataset)).BeginInit(); // // UserDataset // this.UserDataset.DataSetName = "NewDataSet"; ((System.ComponentModel.ISupportInitialize)(this.UserDataset)).EndInit(); } }
This is the source code but when I am trying to access any of this method by making an object of Service1 class I am getting only two function in intellisense that are Equals() and ReferenceEquals(). any idea why am I getting this issue?
Rock Star
-
public class Service1 : System.Web.Services.WebService
{
public DataSet UserDataset = new DataSet();
public SqlDataAdapter UserAdapter = new SqlDataAdapter("Select Query",new SqlConnection("connection string"));\[WebMethod\] public string HelloWorld() { return "Hello World"; } \[WebMethod\] public DataSet GetUserData() { UserAdapter.Fill(UserDataset); return UserDataset; } \[WebMethod\] public DataSet UpdateUserData(DataSet ds) { if(ds != null) { UserAdapter.Update(ds); return ds; } else { return null; } } private void InitializeComponent() { this.UserDataset = new System.Data.DataSet(); ((System.ComponentModel.ISupportInitialize)(this.UserDataset)).BeginInit(); // // UserDataset // this.UserDataset.DataSetName = "NewDataSet"; ((System.ComponentModel.ISupportInitialize)(this.UserDataset)).EndInit(); } }
This is the source code but when I am trying to access any of this method by making an object of Service1 class I am getting only two function in intellisense that are Equals() and ReferenceEquals(). any idea why am I getting this issue?
Rock Star
Can I see the code you are using to call this web service?
-
Can I see the code you are using to call this web service?
Hi, I am trying to call this web service in window application I am assigning generated dataset in web service to one of my dataset in windows application. The code is as follows
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Web.Services;
using System.Configuration.Assemblies;
using System.Xml;namespace UserWindow
{
public partial class UserWindow : Form
{
public UserWindow()
{
InitializeComponent();
}private void LoadData\_Click(object sender, EventArgs e) { DataSet ds = new DataSet(); ds = UserWebService1.Service1.(Here I am getting Reference, GenerateXMLMappings and EqualReference methods) } }
}
Rock Star
-
Hi, I am trying to call this web service in window application I am assigning generated dataset in web service to one of my dataset in windows application. The code is as follows
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Web.Services;
using System.Configuration.Assemblies;
using System.Xml;namespace UserWindow
{
public partial class UserWindow : Form
{
public UserWindow()
{
InitializeComponent();
}private void LoadData\_Click(object sender, EventArgs e) { DataSet ds = new DataSet(); ds = UserWebService1.Service1.(Here I am getting Reference, GenerateXMLMappings and EqualReference methods) } }
}
Rock Star
Try this:
private void LoadData\_Click(object sender, EventArgs e) { DataSet ds = new DataSet(); UserWebService1.Service1 WebSrvc = new UserWebService1.Service1(); ds = WebSrvc.YouFunctionHere; }
-
Try this:
private void LoadData\_Click(object sender, EventArgs e) { DataSet ds = new DataSet(); UserWebService1.Service1 WebSrvc = new UserWebService1.Service1(); ds = WebSrvc.YouFunctionHere; }
-
Thanx Its working now but what was the fault in previous code when I am trying to call methods directly.
Rock Star
You must always unless create an instance of the class before you can use it. UNLESS it's a static object.