我正在尝试使用 asp.net 设置一个简单的 web 服务。这是我的文件后面的代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
namespace MyFirstWebServiceApplication
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class Service1 : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod]
public String MyFirstWebMethod(String firstName, String lastName)
{
//return "How are you " + firstName + " " + lastName + "?";
return String.Format("How are you {0} {1}?", firstName, lastName);
}
}
}
解决方案成功构建。但是,当我运行它,然后尝试调用它时,它不显示预期的 XML,只显示以下消息
此 XML 文件似乎没有任何与之关联的样式信息。文档树如下所示。
这是我得到的截图 http://i45.tinypic.com/2roixvr.png