2017-08-14 100 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 

它的工作原理:)