2016-09-14 514 views
0

我有一個WebService WebService1與方法之前設置GetAssetDetailsData需要像下面的方法錯誤:路徑屬性必須調用send方法Web服務

[WebMethod] 
    public DataTable GetAssetDetailsData(string strAssetId, string strMfg_Sr_No) 
    { 

     DataTable dtGetAssetDetails = new DataTable(); 
     dtGetAssetDetails.TableName = "AssetDetails"; 
     // My coding to get data 
     return dtGetAssetDetails; 
    } 

2個參數strAssetId和strMfg_Sr_No對於消費這項服務,我有一個Windows窗體應用程序在文本框中獲取數據參數並在按鈕單擊時在Datagrind中顯示數據。

private void button1_Click(object sender, EventArgs e) 
{ 
    AssetDetailsService.WebService1 ser = new AssetDetailsService.WebService1(); 
    DataTable dt = ser.GetAssetDetailsData(textBox1.Text.Trim(), textBox2.Text.Trim()); //Getting error at this line 
    dataGridView1.DataSource = dt; 
} 

在按一下按鈕,我得到這個錯誤

path property must be set before calling the send method web service I followed this SO Question but didn't find solution Web Service Error path property must set before calling the send method

+0

退房這裏的答案:[調用Windows項目asp.net的WebMethod](http://stackoverflow.com/questions/19597291/call-asp-net-webmethod-in-windows-項目) –

+0

哪裏向方法提供參數? –

+1

從我的鏈接裏面''使用(var writer = theWebRequest.GetRequestStream())''string send = null; send =「{\」value \「:\」test \「}」;'。這裏是另一個鏈接,如果你想使用GET而不是POST:[我如何發送ASP.NET webservice的參數](http://stackoverflow.com/questions/20843282/how-can-i-send-parameters-for -asp-net-webservice) –

回答

0

你必須在web.config文件「的applicationSettings」部分指定網絡服務的網址。例如,

<applicationSettings> 
    <myapp.My.MySettings> 
     <setting name="myservice" serializeAs="String"> 
     <value>https://myapp.com/service.asmx</value> 
     </setting> 
    </myapp.My.MySettings> 
    </applicationSettings> 
+0

已經添加了這個。 –

+0

你可以把錯誤部分的截圖? – JPatel

相關問題