【问题标题】:Error: path property must be set before calling the send method web service错误:必须在调用发送方法 Web 服务之前设置路径属性
【发布时间】:2016-09-14 10:14:46
【问题描述】:

我有一个WebServiceWebService1,其方法 GetAssetDetailsData 采用 2 个参数 strAssetId 和 strMfg_Sr_No,如下面的方法

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

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

为了使用此服务,我有一个 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;
}

单击按钮时出现此错误

必须在调用发送方法 Web 服务之前设置路径属性 我遵循了这个 SO Question 但没有找到解决方案 Web Service Error path property must set before calling the send method

【问题讨论】:

标签: c# web-services


【解决方案1】:

您必须在 web.config 文件的“applicationSettings”部分指定 web-service url。例如,

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

【讨论】:

    猜你喜欢
    • 2015-08-23
    • 1970-01-01
    • 2014-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-04
    • 1970-01-01
    相关资源
    最近更新 更多