如何配置具有两个端点的WCF服务,以便为每个端点使用不同的Listen
我有一个WCF服务,它使用webHttpBinding公开一个端点,并被
WPF和ASP.NET应用程序使用.一切都很好.
我现在正试图从Windows Phone(WP7)中使用该服务.但是,由于.NET Framework尚未完全赶上WP7,因此System.ServiceModel.Web命名空间不可用,结果是webHttpBinding在WP7中不起作用. 现在,在我的服务上,如果我将webHttpBinding切换为basicHttpBinding,则电话应用程序可以正常工作. 我不想重写我的WPF和ASP.NET应用程序来使用basicHttpBinding. 我知道WCF能够支持多个绑定,我试图配置和运行该服务,以便它为webHttpBinding和basicHttpBinding公开端点.该服务似乎启动良好.但是,WPF& ASP.NET应用程序无法访问它.当我尝试在WP7应用程序中创建服务引用时,我收到以下消息:
我和一位同事玩过baseAddress,address和listenUri属性的各种更改,但没有任何运气.我们现在正处于试验和错误的阶段,这并不是非常有效. <system.serviceModel> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> <bindings> <basicHttpBinding> <binding name="generalBasic" /> </basicHttpBinding> <webHttpBinding> <binding name="general" maxReceivedMessageSize="2147483647"> <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" /> <security mode="None"> <transport clientCredentialType="None" /> </security> </binding> </webHttpBinding> </bindings> <behaviors> <serviceBehaviors> <behavior> <serviceMetadata httpGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> <endpointBehaviors> <behavior name="web"> <webHttp /> </behavior> </endpointBehaviors> </behaviors> <services> <service name="MyProject.GeneralService"> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> <endpoint address="" binding="basicHttpBinding" bindingConfiguration="generalBasic" contract="MyProject.Contracts.IGeneralService" /> <endpoint behaviorConfiguration="web" binding="webHttpBinding" bindingConfiguration="general" contract="MyProject.Contracts.IGeneralService" /> <host> <baseAddresses> <add baseAddress="http://localhost:1726/" /> </baseAddresses> </host> </service> </services> </system.serviceModel> 解决方法
只需使用基本或webhttp端点的值指定address属性即可区分其地址.例如:
<endpoint behaviorConfiguration="web" address="rest" binding="webHttpBinding" bindingConfiguration="general" contract="MyProject.Contracts.IGeneralService" /> 应该解决你的问题 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- windows-server-2008-r2 – 超过4TB的网络共享
- 使用SWAGGER-UI中的Windows身份验证调用WCF
- windows-7 – Windows 7中的SMTP本地服务器? (运行IIS7)
- 如何在Windows Vista及更高版本上进入Windows Flip 3D模式?
- Windows中的signal.alarm替换[Python]
- windows – PsExec将复制.exe,但不会让我传递参数
- Windows 下安装 Memcached
- Windows Phone 7 – 处理ViewModel中的OnNavigatedFrom / O
- windows-7 – Windows 7中IIS的进程名称是什么?
- 什么是最小的Windows(PE)可执行文件?
- 适用于Windows的Vim / Ag g:ctrlp_user_command
- windows – $PATH或/ usr5bin中没有可用的M4
- microsoft-office-365 – 在Office 365中验证后,
- 在Windows下使用linux实用工具的最佳方式是什么?
- haskell – 在Windows 7上安装带有cygwin的Cabal
- 如何将有空间的目录路径传递给windows shell?
- 在Windows Server Core上将USB HD设置为更好的性
- 是否可以使用R命令在Windows上安装pandoc?
- windows下apache + mod_wsgi + python部署flask接
- 如何在Windows上构建64位MinGW Qt应用程序(使用Q