Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wcf “可怕的”;找不到与方案http匹配的基址;如何使它与SSL一起工作?_Wcf_Ssl - Fatal编程技术网

Wcf “可怕的”;找不到与方案http匹配的基址;如何使它与SSL一起工作?

Wcf “可怕的”;找不到与方案http匹配的基址;如何使它与SSL一起工作?,wcf,ssl,Wcf,Ssl,这个问题被问了很多,但我找到的每一个答案都与我已经应用的东西有关。请提供以下信息,我如何让我的服务与SSL一起工作 我试图使用ajax从WCF服务获取JSONP响应,WCF服务在exchange中连接到中间件服务。我的请求由两个字符串组成 我在web.config中的应用程序BLL下有以下xml,而BLL又位于站点X下: <service behaviorConfiguration="ServiceBehavior" name="Locat

这个问题被问了很多,但我找到的每一个答案都与我已经应用的东西有关。请提供以下信息,我如何让我的服务与SSL一起工作

我试图使用ajax从WCF服务获取JSONP响应,WCF服务在exchange中连接到中间件服务。我的请求由两个字符串组成

我在web.config中的应用程序BLL下有以下xml,而BLL又位于站点X下:

        <service behaviorConfiguration="ServiceBehavior"
                 name="LocationService">
            <endpoint
                address=""
                      contract="ILocationService"
                      binding="webHttpBinding"
                      bindingConfiguration="webHttpBindingWithJsonP"
                      behaviorConfiguration="webHttpBehavior">
                <identity>
                    <dns value="localhost"/>
                </identity>
            </endpoint>         
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        </service>

在配置中再进一步:

        <webHttpBinding>
            <binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="true" >
                <security mode="Transport" />
            </binding>
        </webHttpBinding>

服务行为:

<behavior name="ServiceBehavior">
      <serviceMetadata httpGetEnabled="false" />
      <serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>

此应用程序的IIS设置:

  • 检查是否需要SSL
  • 客户端证书:需要
BLL应用程序所在站点的绑定如下:

  • 类型:http;港口:80 ;;IP地址:10.xx.xxx.xxx
  • 类型:https;港口:443;IP地址:10.xx.xxx.xxx
这应该行得通,不是吗?我假定不需要该端点的端点和绑定信息?我忽略了什么吗?

我发现了问题所在

ServiceBehavior没有将httpsGetEnabled设置为true。 所以必须是这样的:

    <behavior name="ServiceBehavior">
      <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
    </behavior>
通过更改mex端点以允许使用与我的服务相同的绑定信息(更多信息:)传递安全元数据,错误消失:

<endpoint address="mex" binding="webHttpBinding" name="MetadataBinding" contract="IMetadataExchange" bindingConfiguration="webHttpBindingWithJsonP"/>

我遇到的最后一个问题是,我没有正确设置安全设置。与其说我在问题中写了什么,不如说:

  <webHttpBinding>
    <binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="false">
        <security mode="Transport">
          <transport clientCredentialType="Certificate" />
        </security>
    </binding>
  </webHttpBinding>

调整为我提供所需jsonp结果的所有内容


我发现一篇文章详细解释了配置过程:

您如何测试您的服务?这个测试的主机是什么?我试图通过一个ajax调用与服务联系,但这对我来说还不够:你在请求什么?我假设您使用的是运行web浏览器的JavaScript,而不是基于WCF的客户端,那么您确定请求的端点正确吗?你是用什么来托管服务的?您能否从IIS Express成功运行测试场景?请参阅我对问题的回答。
  <webHttpBinding>
    <binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="false">
        <security mode="Transport">
          <transport clientCredentialType="Certificate" />
        </security>
    </binding>
  </webHttpBinding>