没有运行时错误。但我无法调用这些网络服务。对于没有类对象作为参数的 Web 方法,调用按钮工作得很好。这是我的代码。
public class WebService : System.Web.Services.WebService
{
[Serializable]
public class Animal {
public int Age { get; set; }
public string Name { get; set; }
public string Sound(string name)
{
return $"{name} shouting";
}
}
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string getAnimal(Animal animal)
{
Animal animal1 = new Animal();
string response = string.Empty;
animal.Age = 5;
animal.Name = "Keesha";
response = animal1.Sound(animal1.Name);
return response;
}
}`
当我运行程序时,它说“测试表单仅适用于以原始类型作为参数的方法。”我添加了图像以获得更清晰的理解。我需要在我的机器上测试这个应用程序,但我无法调试代码,因为调用按钮没有出现。我正在寻求你的帮助。`