[WebMethod]
public string HelloWorld( string id )
{
return id;
}

然后  http://localhost/WebApplication5/Service1.asmx/HelloWorld?id=XXX
在webconfig里面加上
    <webServices>
      <protocols>
        <add name="HttpSoap"/>
        <add name="HttpPost"/>
        <add name="HttpGet"/>
        <add name="Documentation"/>
      </protocols>
    </webServices>

测试结果

  <?xml version="1.0" encoding="utf-8" ?>
  <string xmlns="http://tempuri.org/">XXX</string>