【发布时间】:2012-05-07 15:48:11
【问题描述】:
我无法让 Duplex Web 服务正常工作,我收到此错误:
找不到引用合约的默认端点元素 ServiceModel 客户端配置部分中的“IService1”。这 可能是因为没有为您的应用程序找到配置文件, 或者因为找不到与此合同匹配的端点元素 在客户端元素中。
这是我的单元测试尝试访问服务时抛出的。我发现了类似的 SO 问题:
Could not find default endpoint element
答案是“将配置文件包含到另一个项目中”,但这究竟是什么意思?
- 我是否将服务编译成 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>
输出配置
<?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>
【问题讨论】:
-
你能发布你的客户端配置文件吗?
-
添加了我的配置文件。即使添加“Test_Duplex”(我的命名空间),错误也是一样的。
-
您的托管环境是什么?您还可以删除主机部分中的基地址并查看它是否有效。如果托管在 IIS 上,则主机基地址将被忽略,地址由 IIS 分配
-
我删除了
部分中的所有内容,但仍然找不到端点。我不确定我的托管环境是什么,我在 Visual Studio C#、winXP 上运行它,初始化时它说 ASP.NET Development Server 具有相同的地址,无论我是否声明了
标签: c# wcf web-services soap