我有我可以成功使用的Web服務,但我與其他想通過URL輸入參數的其他人共享我的web服務,例如:// localhost:12345/Lead。 ?ASMX OP = SendFiles &編號= 1234678 &名稱=喬&姓=凱文如何通過URL將參數傳遞到Web服務
我說:
<webServices>
<protocols>
<add name="HttpGet"/>
</protocols>
</webServices>
到我的web.config文件,我SendFile.asmx.cs代碼如下所示:
namespace SendFiles
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://testco.co.za/")]
[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 SendFile : System.Web.Services.WebService
{
[WebMethod]
public bool PostToDB(LoadEntity _lead)
{
ConnectToSQLDB(ConfigurationManager.AppSettings["Server"], ConfigurationManager.AppSettings["DB"],
ConfigurationManager.AppSettings["UserName"], ConfigurationManager.AppSettings["Password"], ref connectionRef);
if (LI.ImportFiles(_lead, ref (error)) == true)
{
return true;
}
else
return false;
}
我嘗試添加:
[OperationContract]
[WebGet]
bool PostToDB(string IDNo, string FName, string SName);
但我得到的,因爲它沒有標記爲抽象,EXTERN或部分,我必須聲明主體錯誤。誰能幫忙?
您是否嘗試過將該方法標記爲Public或Private或Static例如..? – MethodMan