将ServiceReference添加到另一个项目时出错

时间:2018-08-20 13:45:00

标签: asp.net-mvc soap

我有一个由3个项目组成的解决方案:2个类库 ErrandModuleDotNetFW和TestErrandModuleDotNetFW(.NET框架)和一个Web应用程序。参见图片1。

enter image description here

在Web应用程序中,我一直在使用服务引用(SOAP),并且它一直在工作。但是,当我将相同的服务引用添加到类“ ErrandModuleDotNetFW”时,会出现错误:“无法初始化配置系统”。

Web应用程序的app.config文件如下所示:

<configuration>
  <runtime>
    <gcServer enabled="true"/>
  </runtime>
</configuration>

添加了肥皂的类库中的app.config看起来像这样:

<configuration>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IService" />
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="Adress to Server"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService"
        contract="R2S_soap.IService" name="BasicHttpBinding_IService" />
    </client>
  </system.serviceModel>
</configuration>

这就是我初始化服务客户端的方式:

public ServiceClient GetR2S()
{
  var sc = new ServiceClient();
  sc.Endpoint.Address = new System.ServiceModel.EndpointAddress(_url);
  return sc;
}

_url参数是服务器URL(与配置文件“到服务器的地址”相同)。

有什么想法吗?

0 个答案:

没有答案
相关问题