namespace TestWebService1 { /// <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] [ScriptMethod(UseHttpGet=true)] public string getID() { SqlConnection cs = new SqlConnection(@"Server=130-ASQL1-B-001.OSCD.LOCAL;Initial Catalog=AIM;User ID=user;Password=pass"); SqlCommand cmd = new SqlCommand("select id from NIM where stationName='" + System.IO.Path.GetDirectoryName(HttpContext.Current.Request.ServerVariables["REMOTE_USER"]) + "' and availability = 'reachable'", cs); cmd.CommandType = CommandType.Text; cmd.Connection = cs; cs.Open(); SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); return dr["id"].ToString(); dr.Close(); cs.Close(); } } }
<div style="display: hidden;"> <form action='http://localhost:52618/Service1.asmx/HelloWorld?ID=' method="get" target="_self"> <table> <tr> <td>GET ID</td> <td> <input class="frmInput" type="text" size="30" name="id"> </td> </tr> <tr> <td></td> <td align="right"> <input type="submit" id="submitButton" value="Submit" class="button"> </td> </tr> </table> </form> <script language="javascript"> document.getElementById("submitButton").click(); </script> </div>
<?xml version="1.0" encoding="UTF-8"?> <string xmlns="http://tempuri.org/">0</string>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)