在DLL中使用Web服务时出错

时间:2015-10-10 15:50:11

标签: c# winforms web-services

我在.net中有一个网络服务。我已经使用它制作了一个Windows窗体应用程序但是当我创建一个DLL并将其添加为我的项目的引用时,它不起作用并抛出

  

无法找到名称为#34的端点; FaturaServiceSoap"和合同" BimsaFaturaService.FaturaServiceSoap"在服务模型客户端配置部分。

类库项目中的app.config:

<?xml version="1.0"?>
<configuration>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="FaturaServiceSoap">

        </binding>
        <binding name="FaturaServiceSoap1" />
      </basicHttpBinding>
      <customBinding>
        <binding name="FaturaServiceSoap12">
          <textMessageEncoding messageVersion="Soap12" />
          <httpsTransport />
        </binding>
      </customBinding>
    </bindings>
    <client>
      <endpoint name="FaturaServiceSoap" address="https://efaturatest.edoksis.net/FaturaService.asmx" binding="basicHttpBinding" bindingConfiguration="FaturaServiceSoap" contract="BimsaFaturaService.FaturaServiceSoap" />
      <endpoint name="FaturaServiceSoap12" address="https://efaturatest.edoksis.net/FaturaService.asmx" binding="customBinding" bindingConfiguration="FaturaServiceSoap12" contract="BimsaFaturaService.FaturaServiceSoap" />
    </client>
  </system.serviceModel>
  <startup>
    <supportedRuntime version="v2.0.50727" />
  </startup>
</configuration>
winforms app中的

app.config:

<?xml version="1.0"?>
<configuration>
    <startup> 

    <supportedRuntime version="v2.0.50727"/></startup>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="FaturaServiceSoap">
                    <security mode="Transport" />
                </binding>
                <binding name="FaturaServiceSoap1" />
            </basicHttpBinding>
            <customBinding>
                <binding name="FaturaServiceSoap12">
                    <textMessageEncoding messageVersion="Soap12" />
                    <httpsTransport />
                </binding>
            </customBinding>
        </bindings>
        <client>
            <endpoint address="https://efaturatest.edoksis.net/FaturaService.asmx"
                binding="basicHttpBinding" bindingConfiguration="FaturaServiceSoap"
                contract="ServiceReference1.FaturaServiceSoap" name="FaturaServiceSoap" />
            <endpoint address="https://efaturatest.edoksis.net/FaturaService.asmx"
                binding="customBinding" bindingConfiguration="FaturaServiceSoap12"
                contract="ServiceReference1.FaturaServiceSoap" name="FaturaServiceSoap12" />
        </client>
    </system.serviceModel>
</configuration>

我该怎么办?谢谢你的帮助!

1 个答案:

答案 0 :(得分:0)

将配置设置从类库移动到app.config,否则会覆盖它们的值。