MEX在WCF绑定错误 [英] mex binding error in WCF

查看:172
本文介绍了MEX在WCF绑定错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用VSTS 2008 + C#+ .NET 3.0。我使用的是自承载WCF服务。当执行下面的语句,还有下面的绑定未找到错误。我已经发布了我的整个app.config文件,任何想法有什么不好?



  ServiceHost的主机=新的ServiceHost(typeof运算(MyWCFService) ); 



错误消息:




找不到匹配与绑定MetadataExchangeHttpBinding的
端点的计划http的基址。 。已注册的基
址方案是[HTTPS]




完整的app.config:



<预类=郎咸平的XML prettyprint-覆盖> <?XML版本=1.0>?;
<结构>
< system.serviceModel>
<&绑定GT;
<&的wsHttpBinding GT;
<绑定名称=MyBinding
closeTimeout =00:00:10
openTimeout =00:00:20
receiveTimeout =00:00:30
的SendTimeout =00:00:40
bypassProxyOnLocal =false的
transactionFlow =false的
hostNameComparisonMode =WeakWildcard
maxReceivedMessageSize =亿
messageEncoding =MTOM
proxyAddress =HTTP://富/酒吧
textEncoding =UTF-16
useDefaultWebProxy =false的>
<有序的ReliableSession =false的
inactivityTimeout =00:02:00$ B $ =使真/> B:
<安全模式=运输>
<运输clientCredentialType =消化
proxyCredentialType =无
境界=someRealm/>
< /安全>
< /&结合GT;
< /&的wsHttpBinding GT;
< /绑定>
<服务和GT;
<服务名称=MyWCFService
behaviorConfiguration =mexServiceBehavior>
<主机>
< baseAddresses>
<添加baseAddress =htt​​ps://开头本地主机:9090 /为MyService/>
< / baseAddresses>
< /主机>
<端点地址=绑定=的wsHttpBindingbindingConfiguration =MyBinding合同=IMyService/>
<端点地址=MEX绑定=mexHttpBinding合同=IMetadataExchange接口/>
< /服务>
< /服务>
<&行为GT;
< serviceBehaviors>
<行为NAME =mexServiceBehavior>
< serviceMetadata httpGetEnabled =真/>
< /行为>
< / serviceBehaviors>
< /行为>
< /system.serviceModel>
<&启动GT;< supportedRuntime版本=V2.0.50727/>< /启动>< /结构>


解决方案

该基址为您服务定义HTTPS:/ 。/ - 但你MEX地址是HTTP



如果你希望你的服务使用https://开头,你需要使用 mexHttpsBinding 以及



<预类=郎咸平的XML prettyprint-覆盖> <服务和GT;
<服务名称=MyWCFServicebehaviorConfiguration =mexServiceBehavior>
<主机>
< baseAddresses>
<添加baseAddress =htt​​ps://开头本地主机:9090 /为MyService/>
< / baseAddresses>
< /主机>
<端点地址=
结合=的wsHttpBinding
bindingConfiguration =MyBinding
合同=IMyService
/>
<端点地址=MEX
结合=mexHttpsBinding
合同=IMetadataExchange接口
/>
< /服务>
< /服务>



马克


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>

解决方案

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:

<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="mexHttpsBinding" 
                contract="IMetadataExchange" 
        />
    </service>
</services>

Marc

这篇关于MEX在WCF绑定错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆