您好我的网站上有一个演示页面,我正在学习如何从脚本调用webservice 这是我的页面 http://applicazioni.vsc300.it/Mediweb2015/Prova.aspx
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<input name="TXT_CognomePaziente" type="text" id="TXT_CognomePaziente" name="TXT_CognomePaziente" />
&#13;
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
<System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class Service
Inherits System.Web.Services.WebService
' <WebInvoke(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest, Method = "GET")>
<WebMethod()> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
Public Function CercaPaziente(IDPaziente As Integer) As String
Dim serialiser As JavaScriptSerializer = New JavaScriptSerializer()
Dim Paz As New CLS_Paziente
Paz.GetCercaAnagrafica(IDPaziente)
Dim serializer As JavaScriptSerializer = New JavaScriptSerializer()
Dim serializedItems As String = serializer.Serialize(Paz)
Return serializedItems
End Function
End Class
&#13;
这是服务:
{{1}}
它返回一个错误,只能从脚本中调用类定义中带有[ScriptService]属性的Web服务。 但我启用了它! 我该怎么办?
答案 0 :(得分:0)
来自this doc:
如果将多个属性应用于单个程序元素,则属性将包含在一组尖括号中,并用逗号分隔。例如:
<Obsolete(), WebMethod()>
Public Function PageCount(strURL As String) As Integer
(顺便说一下,这很难找到。我无法在MSDN上的任何地方找到它。)所以,这不是你的代码所做的,.NET编译器可能忽略了你的属性共。试试这个,看它是否有效:
<System.Web.Script.Services.ScriptService(), _
WebService(Namespace:="http://tempuri.org/"), _
WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1), _
Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
Public Class Service
Inherits System.Web.Services.WebService