WebService1.asmx
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
' 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 WebService1
Inherits System.Web.Services.WebService
<WebMethod()>
Public Function HelloWorld() As String
Return "Hello World"
End Function
<WebMethod(True)>
Public Function myFunction(ByVal myString As String) As String
Return "Hello " + myString // If i insert breakpoint here the line is reached
End Function
End Class
WebForm1.aspx
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="WebApplication2.WebForm1" %>
<!DOCTYPE html>
<script type="text/javascript">
function onButtonClicked()
{
var retVal = WebApplication2.WebService1.myFunction(document.getElementById("TextBox1").value, WTFHAPPENS, onTimeOut, onError); // From here doesn't go anywhere
}
function WTFHAPPENS(text)
{
document.getElementById("Label1").value = text; // This should be reached but is never reached...
}
function onTimeOut(value) {
alert("TimeOut!");
}
function onError(value) {
alert("Error!");
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" AsyncPostBackTimeout="3600" runat="server">
<Services>
<asp:ServiceReference Path="~/WebService1.asmx" InlineScript="true" />
</Services>
</asp:ScriptManager>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="onButtonClicked(); return false;" CausesValidation="false" />
<asp:Label ID="Label1" runat="server" Text="This will be changed!" />
</div>
</form>
</body>
</html>
Okey,所以在寻找我的问题的答案时遇到了一些麻烦...
有人知道成功方法永远不会被调用吗?
我曾尝试使用Firefox开发人员调试工具对其进行调试,但未找到任何答案。
我的函数从WebService1.asmx调用myFunction webMethod,应该返回一个字符串(确实如此),但从未到达WTFHAPPENS方法。
答案 0 :(得分:0)
问题实际上是我的代码不正确。 Label元素没有.value属性。 我改变了:
@Test
public void testLogin_1(){
login(email, password)
}
@Test
public void testLogin_2(){
login(email2, password2)
}
private void login(String email, String password){
inputEmail(email);
inputPassword(password);
clickSubmit();
Assert.assertEquals();
// do some asserts so if You want to assert some error cases.
}
到
function WTFHAPPENS(text)
{
document.getElementById("Label1").value = text; // This should be reached but is never reached...
}
并且警报弹出窗口可见。
function WTFHAPPENS(value)
{
alert("Succes!");
}