繁体   English   中英

WCF REST服务HTTP到https错误404

[英]WCF rest service http to https error 404

我正在使用Visual Studio2015。我有一个Xamarin Cross-Platfom的项目。 我的WCF Rest Service与http可以正常工作。 我尝试使用HTTPS,但尝试访问资源时收到“找不到404错误”。 您将在配置文件下面找到:

web.config中

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

 <appSettings>
   <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
 </appSettings>
 <system.web>
   <compilation debug="true" targetFramework="4.5.2" />
   <httpRuntime targetFramework="4.5.2" />
 </system.web>
 <system.serviceModel>
<services>
  <service name="PrototypeBHost.PrototypeB"   behaviorConfiguration="ServiceBehaviour">
    <endpoint address="" binding="webHttpBinding" bindingConfiguration="webHttpTransportSecurity"
    behaviorConfiguration="restfulBehavior"
    contract="PrototypeBHost.IprototypeB" />

<endpoint contract="IMetadataExchange" binding="mexHttpsBinding" address="mex" />     
  </service>
</services>
<bindings>
  <webHttpBinding>
    <binding name="webHttpTransportSecurity">
      <security mode="Transport" />
    </binding>
  </webHttpBinding>
</bindings>
<behaviors>
  <endpointBehaviors>
    <behavior name="restfulBehavior">
      <webHttp/>
    </behavior>
  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehaviour">
      <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
      <serviceMetadata httpsGetEnabled="true" httpGetEnabled="false"/>
      <!-- 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="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<protocolMapping>
    <add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>    
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
 </system.serviceModel>
 <system.webServer>
 <modules runAllManagedModulesForAllRequests="true" />
<!--
    To browse web app root directory during debugging, set the value below to true.
    Set to false before deployment to avoid disclosing web app folder information.
  -->
   <directoryBrowse enabled="true" />
  </system.webServer>
</configuration>

对ApplicationHost.config

<site name="PrototypeBHost" id="2">
            <application path="/" applicationPool="Clr4IntegratedAppPool">
                <virtualDirectory path="/" physicalPath="c:\Users\Ludovic\Documents\Visual Studio 2015\Projects\PrototypeB\PrototypeBHost" />
            </application>
            <bindings>
            <!--    <binding protocol="http" bindingInformation="*:9612:192.168.1.106" />
                <binding protocol="http" bindingInformation="*:8023:localhost" />-->
                <binding protocol="https" bindingInformation="*:9612:192.168.1.106" />
                <binding protocol="https" bindingInformation="*:8023:localhost" />  
            </bindings>
        </site>

我遵循了一些有关WCF Rest的教程,但是我对SSL证书有些困惑。 我需要吗? 如何将ssl证书附加到WCF Rest Service? 我错过了什么?

My_WCF_proprieties

我终于发现问题出在哪里,IIS Express的默认证书不起作用,并造成了一些麻烦。 首先,我删除其中一个证书,我在VS2015中使用命令提示符

netsh http delete sslcert ipport=0.0.0.0:44300

之后,我添加一个自签名证书

netsh http add sslcert ipport=0.0.0.0:44300 certhash=fb02ea72ab7443604aa8frib298e43l751ce3606 appid={214124cd-d05b-4309-8p76-9caa44b2b74a}

显示所有证书的命令

netsh http show sslcert > output.txt

它有效:)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM