Webservice error - please help

Discussion in 'ASP .Net' started by Jokke, May 26, 2010.

  1. Jokke

    Jokke Guest

    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
     
    Jokke, May 26, 2010
    #1
    1. Advertising

  2. Jokke

    Patrice Guest

    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).

    --
    Patrice
     
    Patrice, May 26, 2010
    #2
    1. Advertising

  3. Jokke

    Mr. Arnold Guest

    Jokke wrote:
    > 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.
     
    Mr. Arnold, May 26, 2010
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    541
    Chris Uppal
    May 5, 2005
  2. KK
    Replies:
    2
    Views:
    649
    Big Brian
    Oct 14, 2003
  3. MuZZy
    Replies:
    7
    Views:
    1,786
    Mike Hewson
    Jan 7, 2005
  4. Peter Nordström

    Webservice calling a webservice.....Error

    Peter Nordström, Oct 21, 2003, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    181
    Peter Nordström
    Oct 21, 2003
  5. Roberto Giorgetti

    Error connection using webservice locally (3 webservice in balanci

    Roberto Giorgetti, Jun 13, 2006, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    208
    Roberto Giorgetti
    Jun 13, 2006
Loading...

Share This Page