This is a migrated thread and some comments may be shown as answers.

Tooltip + Webservice + JSON + Indexoutofbounds

7 Answers 185 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
Alan T
Top achievements
Rank 1
Alan T asked on 27 Sep 2011, 11:54 AM

Hi all, I know this a more a general .NET question, but hopefully someone can help.
I've got a service that simply returns a string, which i use to populate the Tooltip.

Runs all fine locally through the IIS development environment, but when i deploy it on my server to run through IIS it errors.

Initially the error was due to be not having <webServices> reference in my web.config.

I've now added that in and am getting a different error.

I've limited it down to this line:

    <WebMethod()> _
    <ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
    Public Function GetDataByRegion(ByVal context As Object) As String

System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at System.Web.Services.Protocols.HttpServerType..ctor(Type type)
   at System.Web.Services.Protocols.HttpServerProtocol.Initialize()
   at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)

If it's not specified the service seems to return XML ok.

Whats going on ?

7 Answers, 1 is accepted

Sort by
0
Alan T
Top achievements
Rank 1
answered on 27 Sep 2011, 12:02 PM
Ok i'm guessing it's something to do with the fact i'm passing 'context' as it only seems to occur when i pass parameters.

If this is not the way to pass parameters from the ToolTipManager, than how should i do it ?
0
Alan T
Top achievements
Rank 1
answered on 27 Sep 2011, 01:36 PM
After hours of googling i tried an article that suggested putting the 'hello world' function in the file.

    <WebMethod()> _
    Public Function HelloWorld() As String
        Return "Hello World"
    End Function

This actually ends up giving me a different error. "Web service method name is not valid"


Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System.Web.Script.Services
 
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
<System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class map_service
    Inherits System.Web.Services.WebService
 
    <WebMethod()> _
    Public Function HelloWorld() As String
        Return "Hello World"
    End Function
 
    <WebMethod()> _
    <ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
    Public Function GetDataByRegion(ByVal context As Object) As String
 
        Dim result As String = ""
 
        If context IsNot Nothing Then
            Dim obj As IDictionary
            obj = TryCast(context, IDictionary)
            result = obj("TargetControlID").ToString
        End If
    End Function
 
End Class

As you can see i've pretty much stripped out all logic.
0
Marin Bratanov
Telerik team
answered on 28 Sep 2011, 09:45 AM
Hi Alan,

What I see is that your method does not return the string, so I am not sure how it even compiled. What I can advise is that you start off from the following demo: http://demos.telerik.com/aspnet-ajax/tooltip/examples/webservice/defaultcs.aspx. Please examine it carefully and the information on the signature of the method as well. You can examine it locally in the LiveDemos folder of your RadControls installation.

I tested your scenario by deploying the site to the IIS and things seem to be working correctly: http://screencast.com/t/dzHeMyo1. Please also note that I have changed the asmx file accordingly - to point the exact location of the files and classes in my project so you should make sure this is correct in your case as well. I am also attaching the modified files I tested with as a reference. Please start off from this demo and build your functionality. Once it works there you should be able to incorporate it in your actual project.


Regards,
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Alan T
Top achievements
Rank 1
answered on 28 Sep 2011, 09:54 AM
Marin, thanks for the response .

At the moment i've stripped it out to literally this function

    <WebMethod()> _
    <ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
    Public Function HelloWorld(ByVal context As Object) As String
        Return "Hello World"
    End Function


And i'm calling "HelloWorld" from the radtooltipmanager.

This is where i'm getting this outofbounds error, the moment i add a parameter. I'll check out your example.

I just find it puzzling it works locally.

Thanks.
0
Alan T
Top achievements
Rank 1
answered on 28 Sep 2011, 10:25 AM
Still not having any luck.

Below is the entire contents of what i have in my web service now.

If i go to the service
http://mydomain/map_service.asmx/HelloWorld

System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at System.Web.Services.Protocols.HttpServerType..ctor(Type type)
   at System.Web.Services.Protocols.HttpServerProtocol.Initialize()
   at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)



Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System.Web.Script.Services
 
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
<System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class map_service
    Inherits System.Web.Services.WebService
 
    <WebMethod()> _
    <ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
    Public Function HelloWorld(ByVal context As Object) As String
        Return "Hello World"
    End Function
End Class

Is there something else i need in my web config ? Or something i need to check in IIS ?
It must be one of, because it works through VS development environment

Please note, that if i remove 'ByVal context As Object) it will return 'Hello World'

I can link you to the service itself if that helps.
0
Alan T
Top achievements
Rank 1
answered on 30 Sep 2011, 12:30 AM
I still have not resolved this, does anyone have any suggestions that i can look for in say configuration, if thats what the issue is. 

As mentioned, runs finally locally through VWD environment. But when deployed on server through IIS, throughs outofbounds error mentioned above, only IF the webmethod/scriptmethod has a parameter specified. 
0
Marin Bratanov
Telerik team
answered on 03 Oct 2011, 04:22 PM
Hello Alan,

I am not sure what the reason for this may be. I tested your code as stated in my previous reply even with deployment to IIS and it is working correctly. There is also a screen capture from my experiment there. This leads me to believe that something in your specific project is resulting in this behavior, but I cannot say what. If you open a support ticket, isolate this behavior in a simple, runnable site that reproduces your issue and send it to us we will gladly examine it.


Kind regards,
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
ToolTip
Asked by
Alan T
Top achievements
Rank 1
Answers by
Alan T
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or