获取"无法通过绑定WSHttpBinding找到与端点的方案http匹配的基址.已注册的基址方案为[]"

tan*_*ire 9 wcf wshttpbinding

我已经完成了Stack Overflow并且遵循 SSL和WebHttpBinding 的在线教程.

我收到了与那里提到的相同的错误.我已经恢复到旧的Web配置,如下所示.我的https网站工作正常,我添加了我的WCF作为网站的一部分,以避免打开一个新的端口.

当我收到错误时,我正试图达到类似的效果:

https://localhost/_vti_bin/TestingSQL/sample.svc/mex

<?xml version="1.0"?>
<configuration>
  <system.serviceModel>
<services>
  <service name="SharePointBits.Samples.WCFService.SampleService" behaviorConfiguration="SharePointBits.Samples.WCFService.SampleServiceBehavior">
<host> 
<baseAddresses> 
            <add baseAddress="https://testsite/_vti_bin/TestingSQL/Sample.svc"/> 
        </baseAddresses> 
    </host>

    <endpoint address="https://localhost/_vti_bin/TestingSQL/Sample.svc" binding="wsHttpBinding" contract="SharePointBits.Samples.WCFService.ISampleService" 
bindingConfiguration="wsHttpBindingEndpointBinding">
          <identity>
            <dns value="localhost"/>
      </identity>
  </endpoint>
  <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
  </service>
</services>
<bindings>
  <wsHttpBinding>
    <binding name="wsHttpBinding">
      <security mode="Transport">
        <transport clientCredentialType="None"/>
      </security>
    </binding>
  </wsHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="SharePointBits.Samples.WCFService.SampleServiceBehavior">
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpsGetEnabled="true"/>
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
    <!--<behavior name="">-->
      <!--<serviceMetadata httpGetEnabled="true" />-->
    <!--</behavior>-->
  </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>'
Run Code Online (Sandbox Code Playgroud)

添加网址后,出现新错误:

找不到与绑定MetadataExchangeHttpsBinding的端点的方案https匹配的基址.注册的基地址方案是[].

我尝试了两种方式,都有错误.

添加绝对地址以metadatabinding获取此错误:

ServiceMetadataBehavior的HttpsGetEnabled属性设置为true,HttpsGetUrl属性是相对地址,但没有https基址.提供https基址或将HttpsGetUrl设置为绝对地址.

使用基地址我收到此错误:

找不到与绑定MetadataExchangeHttpsBinding的端点的方案https匹配的基址.注册的基地址方案是[].

注意:我已使用基地址更改了上面的代码.

Jer*_*oen 9

您有一个MEX端点,其地址使WCF认为它是相对的,但您没有提供基址.例如,将MEX端点更改为:

<endpoint address="https://testsite/_vti_bin/TestingSQL/mex" 
          binding="mexHttpsBinding" 
          contract="IMetadataExchange"/>
Run Code Online (Sandbox Code Playgroud)

要么,要么指定BaseAddress并在端点上使用它.

此外,您可能需要调整的serviceMetaData元素,特别是httpsGetUrl.