<%@ WebService Language="VB" CodeBehind="~/App_Code/WebService.vb" Class="WebService" %>
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Data
Imports System.Data.SqlClient
<System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class WebService
Public Function Me_Fill_Flow_Steps() As DataTable
Dim ConStr As String
Dim con As New SqlConnection
ConStr = ConfigurationManager.ConnectionStrings("MyDbConn").ConnectionString
con.ConnectionString = ConStr
If con.State = ConnectionState.Closed Then
con.Open()
End If
Dim cmd As New SqlCommand
cmd.Connection = con
cmd.CommandText = "ME_FILL_MASTER_FLOW_STEPS"
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add(New SqlParameter("@VI_UNIQUE_ID", SqlDbType.Decimal)).Value = "7"
Dim dap As New SqlDataAdapter(cmd)
Dim ds As New DataSet
Try
dap.Fill(ds)
Catch ex As Exception
con.Close()
Return Nothing
Exit Function
End Try
Return ds.Tables(0)
End Function
End Class
and accessing it from aspx file like this
function bindgridview() {
WebService.Me_Fill_Flow_Steps(Fill);
}
jagadeesh.bo...
Member
147 Points
256 Posts
webservice is undefined error
May 02, 2012 05:56 AM|LINK
Dear friends,
i have dotnet framework 4.0 express edition
and using a webservices this is a code of that:
<%@ WebService Language="VB" CodeBehind="~/App_Code/WebService.vb" Class="WebService" %> Imports System.Web Imports System.Web.Services Imports System.Web.Services.Protocols Imports System.Data Imports System.Data.SqlClient <System.Web.Script.Services.ScriptService()> _ <WebService(Namespace:="http://tempuri.org/")> _ <WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _ <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ Public Class WebService Public Function Me_Fill_Flow_Steps() As DataTable Dim ConStr As String Dim con As New SqlConnection ConStr = ConfigurationManager.ConnectionStrings("MyDbConn").ConnectionString con.ConnectionString = ConStr If con.State = ConnectionState.Closed Then con.Open() End If Dim cmd As New SqlCommand cmd.Connection = con cmd.CommandText = "ME_FILL_MASTER_FLOW_STEPS" cmd.CommandType = CommandType.StoredProcedure cmd.Parameters.Add(New SqlParameter("@VI_UNIQUE_ID", SqlDbType.Decimal)).Value = "7" Dim dap As New SqlDataAdapter(cmd) Dim ds As New DataSet Try dap.Fill(ds) Catch ex As Exception con.Close() Return Nothing Exit Function End Try Return ds.Tables(0) End Function End Classfunction bindgridview() { WebService.Me_Fill_Flow_Steps(Fill); }nijhawan.sau...
All-Star
16394 Points
3170 Posts
Re: webservice is undefined error
May 02, 2012 06:00 AM|LINK
Hace you added the referecne to the service in your application?
also the namespaces.?
jagadeesh.bo...
Member
147 Points
256 Posts
Re: webservice is undefined error
May 02, 2012 06:02 AM|LINK
thank u for reply
What reference and which namespace
should i add
nijhawan.sau...
All-Star
16394 Points
3170 Posts
Re: webservice is undefined error
May 02, 2012 06:10 AM|LINK
Have you added the reference to your web service in the aspx project that you have created?
jagadeesh.bo...
Member
147 Points
256 Posts
Re: webservice is undefined error
May 02, 2012 06:13 AM|LINK
Is this correct or i am missing any thing else?
shivalthakur
Participant
1837 Points
531 Posts
Re: webservice is undefined error
May 02, 2012 06:18 AM|LINK
hi use
<asp:ServiceReference Path="~/WebService.asmx" InlineScript="true" />
hoper help you
Response.Write("Success");
Best Of Luck
Shival Thakur
jamshed alam
Member
319 Points
105 Posts
Re: webservice is undefined error
May 02, 2012 06:19 AM|LINK
add refercene of ur webservice if it's in diffrent folder
and thn create object like
using System.Web.Services;
if u using by scriptipting thn
System.Web.Script.Services.ScriptService enable it from web service
mywebservice myweb=new mywebservice();
myweb.Getresult();
jagadeesh.bo...
Member
147 Points
256 Posts
Re: webservice is undefined error
May 02, 2012 06:21 AM|LINK
Thanks but it is not working.
U asked about namespace which namespace should i decalre and where.
Thanks and regards
jagadeesh
chetan.sarod...
All-Star
65619 Points
11118 Posts
Re: webservice is undefined error
May 03, 2012 03:10 AM|LINK
Please refer this
http://omensblog.blogspot.in/2007/07/aspnet-ajax-web-service-calls-from.html
http://www.neilrichards.net/blog/?p=51
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
BU XI - MSFT
All-Star
22367 Points
2704 Posts
Microsoft
Re: webservice is undefined error
May 04, 2012 07:02 AM|LINK
Hello
Suppose that your application's name is WebApplication1, then WebApplication1 is the namespace in this context.
Then you can try, WebApplication1.WebService.YourMethod()
If you have any feedback about my replies, please contact msdnmg@microsoft.com.
Microsoft One Code Framework