【问题标题】:How to access the Web Methods of webservice in the dll without any app.config?如何在没有任何app.config的情况下访问dll中webservice的Web方法?
【发布时间】:2017-07-27 22:05:01
【问题描述】:
  • 我有一个 dll,它使用一个 web 服务的 web 服务引用。

  • 为此,我必须在该 dll 的 app.config 的 中添加

  • 我已经在其他项目中提供了该 dll 的参考。

  • 当我尝试运行应用程序时,它给了我一个异常“找不到默认端点元素。”

  • 我搜索了有关此问题的解决方案,并了解到我必须在我引用 dll 的项目的 app.config 中添加。

  • 那么有什么方法可以在不修改我们引用该 dll 的项目的 app.config 的情况下初始化 Web 服务客户端?

【问题讨论】:

    标签: c# web-services dll windows-applications


    【解决方案1】:

    您想从哪里读取绑定配置?如果你想设置硬编码,你可以使用你的代理类的这个结构..

    public YourServiceSoapClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : 
                base(binding, remoteAddress) {
    }
    

    【讨论】:

      【解决方案2】:

      我已经通过直接下载该 Web 服务的 WSDL 类文件解决了这个问题。

      我遇到了关于网络服务的另一个问题。

      我必须在 dll 以及包含 dll 的父项目中添加 System.Web.Services 引用。

      那么有什么方法可以在不添加引用 System.Web.Services 的情况下使用 Web 服务的 WSDL 类。

      【讨论】:

        猜你喜欢
        • 2015-01-23
        • 2014-12-30
        • 2016-08-11
        • 2012-02-01
        • 2023-04-01
        • 2014-09-08
        • 2016-09-18
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多