C# 找不到终结点异常-WCF Web服务

C# 找不到终结点异常-WCF Web服务,c#,wcf,web-services,soap,C#,Wcf,Web Services,Soap,使双工Web服务正常工作时遇到问题,出现以下错误: 找不到引用协定的默认终结点元素 ServiceModel客户端配置部分中的“IService1”。这 可能是因为找不到应用程序的配置文件, 或者因为找不到与此约定匹配的端点元素 在客户端元素中 这是我的单元测试试图访问服务时抛出的。我发现了类似的问题: 答案是“将配置文件包含到另一个项目中”,但这到底意味着什么 我是否将服务编译成DLL并包含它 我是复制“system.serviceModel”中包含的所有内容还是其中的一个子集 与端点有

使双工Web服务正常工作时遇到问题,出现以下错误:

找不到引用协定的默认终结点元素 ServiceModel客户端配置部分中的“IService1”。这 可能是因为找不到应用程序的配置文件, 或者因为找不到与此约定匹配的端点元素 在客户端元素中

这是我的单元测试试图访问服务时抛出的。我发现了类似的问题:

答案是“将配置文件包含到另一个项目中”,但这到底意味着什么

  • 我是否将服务编译成DLL并包含它
  • 我是复制“system.serviceModel”中包含的所有内容还是其中的一个子集
  • 与端点有关吗
编辑:配置文件

Web.config

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
      <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior name ="svcbh">
          <serviceMetadata httpGetEnabled="False"/>
          <serviceDebug includeExceptionDetailInFaults="False"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <!--<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />-->
    <services>
      <service name ="Test_Duplex.Service1" behaviorConfiguration ="svcbh" >
        <host>
          <baseAddresses>
            <add baseAddress = "http://localhost:3857/Service1.svc" />
          </baseAddresses>
        </host>
        <endpoint name ="duplexendpoint"
                  address =""
                  binding ="wsDualHttpBinding"
                  contract ="Test_Duplex.IService1"/>
        <endpoint name ="MetaDataTcpEndpoint"
                  address="mex"
                  binding="mexHttpBinding"
                  contract="IMetadataExchange"/>
      </service>
    </services>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>

output.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.serviceModel>
        <bindings>
            <wsDualHttpBinding>
                <binding name="duplexendpoint" closeTimeout="00:01:00"      openTimeout="00:01:00"
                    receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
                    transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8"   useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00" />
                    <security mode="Message">
                        <message clientCredentialType="Windows" negotiateServiceCredential="true"
                            algorithmSuite="Default" />
                    </security>
                </binding>
            </wsDualHttpBinding>
        </bindings>
        <client>
             <endpoint address="http://localhost:3857/Service1.svc" binding="wsDualHttpBinding"
                bindingConfiguration="duplexendpoint" contract="Test_Duplex.IService1"
                name="duplexendpoint">
                <identity>
                    <userPrincipalName value="12680@altus.local" />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
</configuration>

这是配置文件的问题。 生成配置文件时,它没有完全指定类型的命名空间。
通常,您只需要
.IService1

我将我的wsdl生成的文件(Service1.svc,output.config)切换到服务引用,并从中获取类定义。你也可以看到他们在这样做

自从老板教我用命令提示符做这件事以来,我一定是一时糊涂


这修复了“找不到端点”错误。

可以发布客户端配置文件吗?添加了我的配置文件。即使在添加“Test_Duplex”(我的命名空间)时,错误也是一样的。您的托管环境是什么?您还可以删除主机部分中的基址,看看它是否有效。如果托管在IIS上,那么主机基址将被忽略,地址由IISI分配。删除了节中的所有内容,仍然找不到端点。我不确定我的托管环境是什么,我正在Visual Studio C#,winXP上运行此程序,初始化时显示ASP.NET开发服务器具有相同的地址,无论是否已声明,抱歉,这不起作用。我尝试了所有可用的名称空间;这是因为它为.NET1.x和2.x客户端创建代理。添加服务引用会覆盖svcutil.exe,为3.x+的客户端创建代理,因此在某种意义上,soem具有更大的灵活性。有关这方面的详细信息,请参阅和。