Web service is undefined

Last post 03-05-2008 7:59 AM by BobRoss. 4 replies.

Sort Posts:

  • Web service is undefined

    03-03-2008, 7:46 AM
    • Member
      16 point Member
    • BobRoss
    • Member since 01-24-2007, 9:18 AM
    • Posts 18

    I am trying to run a web service from a javascript function but am coming across problems.

    It says "'RssService' is undefined" but I cannot see why.
    I know the Namespace is correct and that the service works correctly as I can get it to work in another project easily.

    If I navigate to the webservice/jsdebug and copy the code from this file into the javascript on the page (so to add the proxy code manually) it does one of two things -

    1. If the code from the jsdebug file is inserted into the function calling the webservice it works correctly
    2. if the code is placed otuside of a function I get a "'Type' is undefined'

    Does anyone know why this 'Type is undefined' error is occouring? Why does it not like the Type namespace outside of a function?
    Or does anyone have any other ideas why this may not be working?

  • Re: Web service is undefined

    03-03-2008, 8:35 AM

    Can you provide your source code?

    When you ask a question, remember to click "mark as answered" when you get a reply which answers your question.


    My latest ASP.NET AJAX blog entries.
  • Re: Web service is undefined

    03-03-2008, 9:16 AM
    • Member
      16 point Member
    • BobRoss
    • Member since 01-24-2007, 9:18 AM
    • Posts 18

    Here is the page code -  

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Welcome.aspx.vb" Inherits="Welcome" EnableViewState="false"%>

    <%@ Register Src="~/Controls/Footer.ascx" TagName="Footer" TagPrefix="EOL" %>

    <%@ Register TagPrefix="EOL" TagName="MenuControl" Src="~/Controls/MenuControl.ascx" %>

    <%@ Register TagPrefix="EOL" TagName="HelpPrintControl" Src="~/Controls/HelpPrintControl.ascx" %>

    <%@ OutputCache NoStore="true" Location="None"%>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" >

    <head id="Head1" runat="server">

    <title>vbeiWelcome</title>

    <link id="MainStyle" media="screen" href="~/stylesheet/SE/MainStyle.css" type="text/css" rel="stylesheet" runat=server/>

    <link id="Print" media="print" href="~/stylesheet/SE/Print.css" type="text/css" rel="stylesheet" runat=server/>

    <link rel="shortcut icon" href="~/Images/favicon.ico" />

    <script language=javascript type="text/javascript">

     

    function pageLoad()

    {

     

    RssService.ReturnRSS(
    "http://www.microsoft.com/feeds/msdn/en-us/windowsvista/vista_en_us.xml",GetRssContent_Sucess,GetRssContent_Failure );

    PageMethods.set_timeout(100 * 1000);

    PageMethods.set_defaultSucceededCallback(GetRssContent_Sucess);

    PageMethods.set_defaultFailedCallback(GetRssContent_Failure);

    PageMethods.set_defaultUserContext(
    "RSS");

    //GetRssContent();

    }

     

    //function GetRssContent(){PageMethods.RetRSS("http://www.microsoft.com/feeds/msdn/en-us/windowsvista/vista_en_us.xml");}

     

    function GetRssContent_Sucess(result, userContext, methodName)

    {

    $get(
    "NewsContentDiv").innerHTML = result;

    }

     

    function GetRssContent_Failure(result, userContext, methodName)

    {

    $get(
    "NewsContentDiv").innerHTML = "<div style='padding:5px 3px; 5px 0px' >No news available.</div>";

    }

     

    </script> </head>

    <body id="eonline">

    <div id="wrap">

    <form id="form1" runat="server">

    <asp:ScriptManager ID="ScriptManager2" runat="server" EnablePageMethods=true >

    <Services>

    <asp:ServiceReference Path="RssService.asmx" />

    </Services>

    </asp:ScriptManager>

    <EOL:MenuControl id="MainMenu" runat="server" Section="Default"/>

    <div id="HeadSub">

    <EOL:HelpPrintControl ID="HelpPrint" runat="server" HelpCode="G1" />

    </div>

    <!-- content for EOL.NET starts here -->

    <div id="boxOne">

    <div class="boxcontent">

    <div class="bi">

    <div class="bt"><div></div></div>

    <div class="cont">

    <h1><asp:Label ID="WelcomeText" runat="server" Text="vbeiWelcomeToEOnLine" /></h1>

    <div class="welcometext">

    <asp:Label ID="HelloLabel" runat="server" Text="vbeiHello"></asp:Label>

    <asp:Label ID="OperatorNameLabel" runat="server" CssClass="Highlight"></asp:Label><br />

    <br />

    <asp:Label ID="LastSessionLabel" runat="server" Text="vbeiLastSession"></asp:Label>

    <asp:Label ID="LastSessionDateLabel" runat="server" CssClass="Highlight"></asp:Label><br />

    <br />

    <asp:Label ID="PartnerLaboratoryLabel" runat="server" Text="vbeiPartnerLaboratory"></asp:Label>

    <asp:Label ID="PartnerNameLabel" runat="server" CssClass="Highlight"></asp:Label><asp:Label

    ID="PartnerCityLabel" runat="server" CssClass="Highlight"></asp:Label><br /><br />

    <div runat=server id="NewsDiv">

    <asp:Table ID="NewsTitleBar" runat="server" CssClass="NewsTitle" Width="100%">

    <asp:TableRow>

    <asp:TableCell>

    <asp:Label ID="NewsTitleLabel" Text="vbeiENews" runat="server" />

    </asp:TableCell>

    </asp:TableRow>

    </asp:Table>

    <div runat=server id="NewsContentDiv" class="NewsDiv">

    <div style="text-align:center;padding:2px;">

    <asp:Image ID="AjaxLoader4" runat="server" ImageUrl="~/Images/ajax-loader-4grids.gif" />

    </div>

    </div>

    </div>

    </div>

    </div>

    <div class="bb"><div></div></div>

    </div>

    </div>

    <EOL:Footer ID="Footer1" runat="server" />

    </div>

    </form>

    </div> </body>

    </html>

     

    And here is my web service code -

     

    Imports System.Web

    Imports System.Web.Services

    Imports System.Web.Services.Protocols

    Imports System.Net

    Imports System.Data

    Imports System.Web.Script.Services
    <WebService(Namespace:="http://tempuri.org/")> _

    <WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _

    <
    Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _

    <ScriptService()> _

    Public Class RssService

    Inherits System.Web.Services.WebService

    <WebMethod()> _

    Public Function ReturnRSS(ByVal RSSAddress As String) As String

    Dim ContentString As String = ""

    Dim Ds As New DataSet

    Dim RSSRequest As WebRequest = WebRequest.Create(RSSAddress)

    Dim Pr As New WebProxy("http://192.168.161.1:8080/", True)

    RSSRequest.Proxy = Pr

    RSSRequest.Timeout = 1000 * 10

    Try

    Dim WebResp As WebResponse = RSSRequest.GetResponseDim XmlReader As New System.Xml.XmlTextReader(WebResp.GetResponseStream)

    Ds.ReadXml(XmlReader)

    Dim Alternate As Boolean = True

    ContentString = "<div Class="""" style=""height:150px;overflow-y:auto;""><TABLE><TBODY>"

    For Each Row As DataRow In Ds.Tables("Item").Rows

    If Alternate Then

    ContentString += "<TR Class=""AlternateSearchRow""><TD style=""padding:5px 5px 5px 5px;"">"

    Alternate = False

    Else

    ContentString += "<TR Class=""SearchRow""><TD style=""padding:5px 5px 5px 5px;"">"

    Alternate = True

    End If

    ContentString += "<a href="" mce_href=""" + Row("link") + """><u>" + Row("title") + "</u></a><br><br>"

    ContentString += Row("description") + "<br>"

    ContentString += "</TD></TR>"

    Next

    ContentString += "</TBODY><TABLE></div>"

    Catch ex As Exception

    Throw ex

    End Try

     

    Return ContentString

    End Function

    End Class

     

    Is that all the code needed?

  • Re: Web service is undefined

    03-03-2008, 12:18 PM
    • Contributor
      2,422 point Contributor
    • kirchi
    • Member since 03-07-2007, 7:47 AM
    • Posts 328

    Hi BobRoss,

    Did you try to place javascript pageLoad function after ScriptManager control?

     

    My blog: http://blog.devarchive.net
    My samples: http://devarchive.net
  • Re: Web service is undefined

    03-05-2008, 7:59 AM
    • Member
      16 point Member
    • BobRoss
    • Member since 01-24-2007, 9:18 AM
    • Posts 18

    Gave that a try not to no avail.

    Thanks anyway.

     

    I'm still looking for an answer if anyone has any ideas?

Page 1 of 1 (5 items)