Webservice error - please help

J

Jokke

Hi,

I try to set up a very simple webservice, to feed an AutoCompleteExtender a
list of locations (postal codes + places). In my test page, the textbox does
not do anything at all (no error either).
I have debugged the webservice, and it returns the dataset just fine.
What am I missing?

VS 2008, Ajax Toolkit for 3.5

TESTPAGE (= content page, the master page contains the ToolkitScriptManager
enclosed in form tags):

<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master"
AutoEventWireup="false" CodeFile="TestWebservice.aspx.vb"
Inherits="TestPages_TestWebservice" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit"
TagPrefix="asp" %>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent"
Runat="Server">
<asp:TextBox ID="txtTestPostcode" runat="server"/>
<asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"
TargetControlID="txtTestPostcode"
ServiceMethod="GetPostalCodes"
ServicePath="../WebServices/wsPostalCodes.asmx"
MinimumPrefixLength="2"
CompletionInterval="1000"
EnableCaching="true">
</asp:AutoCompleteExtender>
</asp:Content>

CODE IN "~/Webservices/wsPostalCodes.asmx:

<%@ WebService Language="VB" CodeBehind="~/App_Code/wsPostalCodes.vb"
Class="wsPostalCodes" %>

CODE IN "~/App_Code/wsPostalCodes.vb:

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 wsPostalCodes
Inherits System.Web.Services.WebService

Private Function GetListofPlaces() As DataSet
Dim strConn As String =
System.Configuration.ConfigurationManager.ConnectionStrings("InoptecPlusConnectionString").ConnectionString
Dim strSQL As String = "SELECT BelLocation FROM vwPostalCodesBEL"
strSQL = "SELECT PostCode + N' ' + Location AS BelLocation FROM
PostcodesBEL"
Dim objConn As New SqlConnection(strConn)
Dim cmd As New SqlCommand(strSQL, objConn)
objConn.Open()
Dim da As New SqlDataAdapter()
da.SelectCommand = cmd
Dim ds As New DataSet()
da.Fill(ds)
objConn.Close()
'Return the DataSet
Return ds
End Function

<WebMethod()> _
Public Function GetPostalCodes() As DataSet
Return GetListofPlaces()
End Function
End Class
 
P

Patrice

Hello,

AFAIK the service should return a list of strings, not a dataset... Also you
may want to double check the location
(ServicePath="~/WebServices/wsPostalCodes.asmx" against
ServicePath="../WebServices/wsPostalCodes.asmx" deepdning on where exactly
is your WebServices folder...)

If it still fails I would start with the simplest possible code (for example
a regular page and a web service that returns dummy data with the regular
ScriptManager).
 
M

Mr. Arnold

Jokke said:
Hi,

I try to set up a very simple webservice, to feed an
AutoCompleteExtender a list of locations (postal codes + places). In my
test page, the textbox does not do anything at all (no error either).
I have debugged the webservice, and it returns the dataset just fine.
What am I missing?

VS 2008, Ajax Toolkit for 3.5

TESTPAGE (= content page, the master page contains the
ToolkitScriptManager enclosed in form tags):

<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master"
AutoEventWireup="false" CodeFile="TestWebservice.aspx.vb"
Inherits="TestPages_TestWebservice" %>
<%@ Register Assembly="AjaxControlToolkit"
Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent"
Runat="Server">
<asp:TextBox ID="txtTestPostcode" runat="server"/>
<asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"
TargetControlID="txtTestPostcode"
ServiceMethod="GetPostalCodes"
ServicePath="../WebServices/wsPostalCodes.asmx"
MinimumPrefixLength="2"
CompletionInterval="1000"
EnableCaching="true">
</asp:AutoCompleteExtender>
</asp:Content>

CODE IN "~/Webservices/wsPostalCodes.asmx:

<%@ WebService Language="VB" CodeBehind="~/App_Code/wsPostalCodes.vb"
Class="wsPostalCodes" %>

CODE IN "~/App_Code/wsPostalCodes.vb:

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 wsPostalCodes
Inherits System.Web.Services.WebService

Private Function GetListofPlaces() As DataSet
Dim strConn As String =
System.Configuration.ConfigurationManager.ConnectionStrings("InoptecPlusConnectionString").ConnectionString

Dim strSQL As String = "SELECT BelLocation FROM vwPostalCodesBEL"
strSQL = "SELECT PostCode + N' ' + Location AS BelLocation FROM
PostcodesBEL"
Dim objConn As New SqlConnection(strConn)
Dim cmd As New SqlCommand(strSQL, objConn)
objConn.Open()
Dim da As New SqlDataAdapter()
da.SelectCommand = cmd
Dim ds As New DataSet()
da.Fill(ds)
objConn.Close()
'Return the DataSet
Return ds
End Function

<WebMethod()> _
Public Function GetPostalCodes() As DataSet
Return GetListofPlaces()
End Function
End Class

Maybe, you need to be using a listview or grid (show multiple rows),
instead of a textbox.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,787
Messages
2,569,630
Members
45,334
Latest member
66Zeinab9

Latest Threads

Top