webservice - unknown web method parameter name methodname

こ雲淡風輕ζ 提交于 2019-12-09 03:36:31

问题


I called a webservice for fetching items in fullcalendar. The method is never called and firebug gives this error:

*"POST [http]://localhost:50536/FullCalendar/ServicioFullCalendar.asmx/GetEventosCalendario POST [http]://localhost:50536/FullCalendar/ServicioFullCalendar.asmx/GetEventosCalendario

500 Internal Server Error 1.01s" "unknown web method parameter name methodname"*

Here is the asmx.vb code:

    <System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://localhost/uva/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class ServicioFullCalendar
    Inherits System.Web.Services.WebService

    <ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
    <WebMethod(MessageName:="ObtieneEventos")> _
    Public Shared Function GetEventosCalendario(ByVal startDate As String, ByVal endDate As String) As String
        Try
            Return CalendarioMensualDAO.Instance.getEventos(startDate, endDate)

        Catch ex As Exception
            Throw New Exception("FullCalendar:GetEventos: " & ex.Message)
        Finally

        End Try
    End Function

The webservice is "loaded" from the fullcalendar as follows:

events: "ServicioFullCalendar.asmx/GetEventosCalendario",

回答1:


That was the mistake: the method had to be "not Shared", and without the "Messagename":

<ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
<WebMethod()> _
Public Function GetEventosCalendario(ByVal startDate As String, ByVal endDate As String) As String
    Try
        Return CalendarioMensualDAO.Instance.getEventos(startDate, endDate)

    Catch ex As Exception
        Throw New Exception("FullCalendar:getEventos: " & ex.Message)
    Finally

    End Try
End Function



回答2:


I recommend you use Fiddler to look at the network traffic and see what's being sent to the service. Then figure out why it's being sent that way.

It seems likely that you really are somehow sending a parameter named "methodname".




回答3:


I had the same problem and after spending a lot of time realized that the method was marked as protected and not PUBLIC. I made it public and it started working.



来源:https://stackoverflow.com/questions/4543347/webservice-unknown-web-method-parameter-name-methodname

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!