2017-08-14 76 views
0

我正在使用visual studio 2015.我有一个Xamarin Cross-Platfom的项目。 我的WCF Rest服务可以正常使用http。我试图使用HTTPS,但当我尝试访问我的资源时收到“404错误未找到”。 你会发现下面的CONFIGS文件:WCF rest service http to 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休息一些教程,但我是一个有点困惑与SSL证书。我需要它吗?我如何将ssl certificat附加到WCF Rest服务?我错过了什么?

My_WCF_proprieties

+0

您是否配置IIS以使用SS L· – hugoterelle

+0

不,我把我的帖子末尾的一张图片与我的wcf礼仪挂钩。我会检查这一点。 – Ludovic

+0

你可以用简化版本的服务创建一个github仓库吗? – hugoterelle

回答

1

我终于找到了在那里有问题,与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 

它的工作原理:)