【问题标题】:while calling a webservice from the code,it gives a illegal characters in path error从代码调用网络服务时,路径错误中出现非法字符
【发布时间】:2011-03-24 22:45:08
【问题描述】:

我正在从静态类调用 web 服务函数...... 代码如下:

  public static class ERPBOServiceHandler {
    private static ERPBOService _service = new ERPBOService();
    private static bool _connected = false;

    /// <summary>
    /// Connect to the ERPBO WebService to access all WebService methods
    /// </summary>
    /// <param name="url">The URL of the webservice to connect to.</param>
    /// <returns>Returns true if the web service connection succeded, else false.</returns>
    public static bool Connect(string url) {
           try {
          _service.Url = url;
        _service.Discover();
        _connected = true;
        return true;
      } catch (Exception exc) {
        ERPLog.LogException("ERPBOServiceHandler.Connect", exc);
        //discover failed, maening that we failed to contact the web service. So Web Service is not connected.
        System.Windows.Forms.MessageBox.Show("Error while connecting to webservice\nTrying to connect to: " + url + "\n\n" + exc.ToString());
        _connected = false;
        ERPEngine.SetStatus(false);
        return false;
      }
    }
}

我正在尝试使用这个静态类连接到 web 服务....当我使用适当的 GUI 打开应用程序时,这工作正常....但是如果我尝试使用命令行参数调用应用程序然后使用它webservice 类在路径错误中给出非法字符。

我尝试将 url 传递到消息框中,看起来路径很好。 注意:我从用 xml 编写的设置文件中获取 web 服务的路径。 路径是这样定义的:

<ERPBOWebServicePath>http://localhost:4744/ERPBOService.asmx</ERPBOWebServicePath>  

当我使用命令行参数调用它时出了什么问题..

【问题讨论】:

    标签: c# web-services command-line-arguments


    【解决方案1】:

    解决了这个问题。问题是我使用嵌套的静态构造函数。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-01
      • 1970-01-01
      • 2011-12-06
      • 2013-02-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多