WCF 中的 mex 绑定错误
我使用的是 VSTS 2008 + C# + .NET 3.0。 我正在使用自托管 WCF 服务。 执行以下语句时,出现以下“找不到绑定”错误。 我已经发布了整个 app.config 文件,您知道哪里出了问题吗?
ServiceHost host = new ServiceHost(typeof(MyWCFService));
错误信息:
找不到与 http 方案匹配的基地址 具有绑定 MetadataExchangeHttpBinding 的端点。 注册基地 地址方案是 [https]。
完整的应用程序配置:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="MyBinding"
closeTimeout="00:00:10"
openTimeout="00:00:20"
receiveTimeout="00:00:30"
sendTimeout="00:00:40"
bypassProxyOnLocal="false"
transactionFlow="false"
hostNameComparisonMode="WeakWildcard"
maxReceivedMessageSize="100000000"
messageEncoding="Mtom"
proxyAddress="http://foo/bar"
textEncoding="utf-16"
useDefaultWebProxy="false">
<reliableSession ordered="false"
inactivityTimeout="00:02:00"
enabled="true" />
<security mode="Transport">
<transport clientCredentialType="Digest"
proxyCredentialType="None"
realm="someRealm" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="MyWCFService"
behaviorConfiguration="mexServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="https://localhost:9090/MyService"/>
</baseAddresses>
</host>
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="MyBinding" contract="IMyService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="mexServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>
I am using VSTS 2008 + C# + .NET 3.0. I am using a self-hosted WCF service. When executing the following statement, there is the following "binding not found" error. I have posted my whole app.config file, any ideas what is wrong?
ServiceHost host = new ServiceHost(typeof(MyWCFService));
Error message:
Could not find a base address that matches scheme http for the
endpoint with binding MetadataExchangeHttpBinding. Registered base
address schemes are [https].
Full app.config:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="MyBinding"
closeTimeout="00:00:10"
openTimeout="00:00:20"
receiveTimeout="00:00:30"
sendTimeout="00:00:40"
bypassProxyOnLocal="false"
transactionFlow="false"
hostNameComparisonMode="WeakWildcard"
maxReceivedMessageSize="100000000"
messageEncoding="Mtom"
proxyAddress="http://foo/bar"
textEncoding="utf-16"
useDefaultWebProxy="false">
<reliableSession ordered="false"
inactivityTimeout="00:02:00"
enabled="true" />
<security mode="Transport">
<transport clientCredentialType="Digest"
proxyCredentialType="None"
realm="someRealm" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="MyWCFService"
behaviorConfiguration="mexServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="https://localhost:9090/MyService"/>
</baseAddresses>
</host>
<endpoint address="" binding="wsHttpBinding" bindingConfiguration="MyBinding" contract="IMyService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="mexServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的服务的基址定义为“HTTPS://” - 但您的墨西哥地址是“HTTP”。
如果您希望服务使用 https://,则还需要使用 mexHttpsBinding:
Marc
The base address for your service defines "HTTPS://" - but your mex address is "HTTP".
If you want your service to use https://, you'll need to use the mexHttpsBinding as well:
Marc
我可以去双倍分数吗? :)
当您使用 WS-Http 时,您将绑定到 HTTPS 协议,因此您需要使用正确的 MEX 绑定;
Can I go for the double score? :)
As you're using WS-Http you are binding to an HTTPS protocol, so you need to use the correct MEX binding;
我在评论中提出了一个问题 Marc_s 答案
marc_s已回答
因此,解决方案是使用相同的address="mex" 和 不同 绑定来声明多个端点,如下所示
最近我发现使用一个可用于在测试中启用 MEX 的配置开关会更容易并在 Live 上禁用。
来自http://msdn.microsoft.com/en-us/library/ aa395224.aspx
自定义服务主机 MSDN 文章中的示例代码
I've asked a question in a comment for Marc_s answer
marc_s answered
So solution is to declare multiple endpoints with the SAME address="mex" and different bindings like the following
Recently I found that it's easier to have one configuration switch that can be used to enable MEX on test and disable on Live.
From http://msdn.microsoft.com/en-us/library/aa395224.aspx
Example code from Custom Service Host MSDN article