我有一个提供两个接口的Web服务,一个是“MyAppNameData”,另一个是“MyAppNameSync”。我正在向WPF应用程序添加两个服务引用。在代码中,当我使用“MyAppNameData”引用时,没有出现错误。但是当我使用“MyAppNameSync”时,会生成以下错误:
Could not find default endpoint element that references contract 'MyAppNameSync.IMyAppNameSync' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.
我以完全相同的方式添加了这两个引用,但是MyAppNameData是使用BasicHttpBinding添加的,而MyAppNameSync是使用WSHttpBinding添加的。我不知道为什么会出现这种情况。
以下是客户端app.config文件中的serviceModel元素。正如您所看到的,有一个endpoint元素引用了合同'MyAppNameSync.IMyAppNameSync',这与错误消息所说的相反:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IMyAppNameData"
closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00"
sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288"
maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8"
transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192"
maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="WSHttpBinding_IMyAppNameSync" 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"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192"
maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows"
proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows"
negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://computername.domainname.home/MyAppNameSyncService/MyAppNameData.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IMyAppNameData"
contract="MyAppNameData.IMyAppNameData"
name="BasicHttpBinding_IMyAppNameData" />
<endpoint address="http://computername.domainname.home/MyAppNameSyncService/MyAppNameSync.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IMyAppNameSync"
contract="MyAppNameSync.IMyAppNameSync"
name="WSHttpBinding_IMyAppNameSync">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
任何建议都将不胜感激。
谢谢。
wsHttpBinding
?如果将wsHttpBinding
切换为basicHttpBinding
,它是否能正常工作?基本上,您能否确定是wsHttpBinding
语法导致问题,还是多个绑定导致问题? - RachelMyAppNameSync
?在此之前,你不会知道问题是否出现在绑定上,还是双重绑定上。 - sellmeadog