1

I have a WebService WebService1 with a method GetAssetDetailsData takes 2 parameters strAssetId and strMfg_Sr_No like the following method

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

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

For consuming this service I have a windows form application takes data parameters in textbox and show data in Datagrind on button click.

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;
}

On button click I got this error

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

Community
  • 1
  • 1
Sabyasachi Mishra
  • 1,677
  • 2
  • 31
  • 49
  • Check out the answer here: [call asp.net webmethod in windows project](http://stackoverflow.com/questions/19597291/call-asp-net-webmethod-in-windows-project) – Keyur PATEL Sep 14 '16 at 10:22
  • Where to provide parameters to method? – Sabyasachi Mishra Sep 14 '16 at 10:37
  • 1
    From my link, its inside `using (var writer = theWebRequest.GetRequestStream())` with `string send = null; send = "{\"value\":\"test\"}";`. Here is another link if you want to use GET instead of POST: [How can I send parameters for ASP.NET webservice](http://stackoverflow.com/questions/20843282/how-can-i-send-parameters-for-asp-net-webservice) – Keyur PATEL Sep 15 '16 at 01:51

1 Answers1

0

You have to specify web-service url in "applicationSettings" section of web.config file. For example,

  <applicationSettings>
    <myapp.My.MySettings>
      <setting name="myservice" serializeAs="String">
        <value>https://myapp.com/service.asmx</value>
      </setting>
    </myapp.My.MySettings>
  </applicationSettings>
JPatel
  • 103
  • 1
  • 6