Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/317.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
C# .net WCF获取HTTPS 400错误请求,但可与Http配合使用_C#_.net_Wcf_Ssl_Https - Fatal编程技术网

C# .net WCF获取HTTPS 400错误请求,但可与Http配合使用

C# .net WCF获取HTTPS 400错误请求,但可与Http配合使用,c#,.net,wcf,ssl,https,C#,.net,Wcf,Ssl,Https,我在windows Server 2008 R2上有一个WCF。我有一个SSL证书 使用IE时,http URL工作正常,我可以获取数据,但使用Https时,我的请求有400个错误 在我的wcf的web.config下面: <?xml version="1.0" encoding="utf-8"?> 对于您的部分,您是否尝试过为HTTPS添加端点,如下所示: <services> <service behaviorConfiguration="Servi

我在windows Server 2008 R2上有一个WCF。我有一个SSL证书

使用IE时,http URL工作正常,我可以获取数据,但使用Https时,我的请求有400个错误

在我的wcf的web.config下面:

<?xml version="1.0" encoding="utf-8"?>

对于您的部分,您是否尝试过为HTTPS添加端点,如下所示:

<services>
    <service behaviorConfiguration="ServiceRequestResourcesBehaviors" 
        name="BaseSite.ServiceRequestResources">

        <endpoint address="" 
          behaviorConfiguration="ServiceRequestResourcesAspNetAjaxBehaviorHttps" 
          binding="basicHttpBinding" 
          bindingConfiguration="TransportSecurity"
          contract="BaseSite.ServiceRequestResources" />

        <endpoint address="" 
          behaviorConfiguration="ServiceRequestResourcesAspNetAjaxBehavior" 
          binding="webHttpBinding" contract="BaseSite.ServiceRequestResources" />

        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
    </service>      
</services>

对于您的部分,您是否尝试过为HTTPS添加端点,如下所示:

<services>
    <service behaviorConfiguration="ServiceRequestResourcesBehaviors" 
        name="BaseSite.ServiceRequestResources">

        <endpoint address="" 
          behaviorConfiguration="ServiceRequestResourcesAspNetAjaxBehaviorHttps" 
          binding="basicHttpBinding" 
          bindingConfiguration="TransportSecurity"
          contract="BaseSite.ServiceRequestResources" />

        <endpoint address="" 
          behaviorConfiguration="ServiceRequestResourcesAspNetAjaxBehavior" 
          binding="webHttpBinding" contract="BaseSite.ServiceRequestResources" />

        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
    </service>      
</services>

经过大量测试,它开始工作了。我需要在webHttpBinding而不是basicHttpBinding中配置bindings部分,但我不知道为什么

在“我的绑定”部分下面:

<bindings>
    <webHttpBinding>
        <binding name="TransportSecurity">
            <security mode="Transport">
                <transport clientCredentialType="None" />
            </security>
        </binding>
    </webHttpBinding>
</bindings>

经过大量测试,它开始工作了。我需要在webHttpBinding而不是basicHttpBinding中配置bindings部分,但我不知道为什么

在“我的绑定”部分下面:

<bindings>
    <webHttpBinding>
        <binding name="TransportSecurity">
            <security mode="Transport">
                <transport clientCredentialType="None" />
            </security>
        </binding>
    </webHttpBinding>
</bindings>

正在尝试将SvcTraceViewer日志添加到您的配置中,以获取有关错误的更多详细信息。使用WCF时,任何类型的证书警告都将导致错误400。当您直接转到URL时,您是否收到任何警告?使用SvcTraceViewer,我发现错误:System.Xml.xmleexception:无法读取邮件正文,因为当我直接转到URL时,它是空的警告…尝试将SvcTraceViewer日志添加到您的配置以获取有关错误的详细信息。任何类型的证书警告都将导致错误400,当使用WCF时。当您直接转到URL时,是否收到任何警告?使用SvcTraceViewer,我发现错误:System.Xml.xmleexception:无法读取邮件正文,因为当我直接转到URL时,它是空的警告。。。。