簡體   English   中英

設置WCF傳輸和消息安全性

[英]Setting up WCF Transport and Message Security

我正在嘗試使用WCF服務設置傳輸和郵件安全性。

我已經安裝了本地SSL證書。 但我收到此錯誤:

Error: Cannot obtain Metadata from http://localhost:57458/Service1.svc If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address.  For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata Exchange Error    URI: http://localhost:57458/Service1.svc    Metadata contains a reference that cannot be resolved: 'http://localhost:57458/Service1.svc'.    The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.HTTP GET Error    URI: http://localhost:57458/Service1.svc    There was an error downloading 'http://localhost:57458/Service1.svc'.    The request failed with the error message:--<html>    <head>        <title>Could not find a base address that matches scheme https for the endpoint with binding WSHttpBinding. Registered base address schemes are [http].</title>        <style>         body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;}          p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}         b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}         H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }         H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }         pre {font-family:"Lucida Console";font-size: .9em}         .marker {font-weight: bold; color: black;text-decoration: none;}         .version {color: gray;}         .error {margin-bottom: 10px;}         .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }        </style>    </head>    <body bgcolor="white">            <span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1>            <h2> <i>Could not find a base address that matches scheme https for the endpoint with binding WSHttpBinding. Registered base address schemes are [http].</i> </h2></span>            <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">            <b> Description: </b>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.            <br><br>            <b> Exception Details: </b>System.InvalidOperationException: Could not find a base address that matches scheme https for the endpoint with binding WSHttpBinding. Registered base address schemes are [http].<br><br>            <b>Source Error:</b> <br><br>            <table width=100% bgcolor="#ffffcc">               <tr>                  <td>                      <code>An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.</code>                  </td>               </tr>            </table>            <br>            <b>Stack Trace:</b> <br><br>            <table width=100% bgcolor="#ffffcc">               <tr>                  <td>                      <code><pre>[InvalidOperationException: Could not find a base address that matches scheme https for the endpoint with binding WSHttpBinding. Registered base address schemes are [http].]   System.ServiceModel.ServiceHostBase.MakeAbsoluteUri(Uri relativeOrAbsoluteUri, Binding binding, UriSchemeKeyedCollection baseAddresses) +12298460   System.ServiceModel.Description.ConfigLoader.LoadServiceDescription(ServiceHostBase host, ServiceDescription description, ServiceElement serviceElement, Action`1 addBaseAddress) +12295813   System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, ServiceElement serviceSection) +67   System.ServiceModel.ServiceHostBase.ApplyConfiguration() +108   System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses) +192   System.ServiceModel.ServiceHost.InitializeDescription(Type serviceType, UriSchemeKeyedCollection baseAddresses) +49   System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses) +151   System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(Type serviceType, Uri[] baseAddresses) +30   System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +422   System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +1440   System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +44   System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +615[ServiceActivationException: The service '/Service1.svc' cannot be activated due to an exception during compilation.  The exception message is: Could not find a base address that matches scheme https for the endpoint with binding WSHttpBinding. Registered base address schemes are [http]..]   System.Runtime.AsyncResult.End(IAsyncResult result) +687598   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +190   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, String routeServiceVirtualPath, Boolean flowContext, Boolean ensureWFService) +234   System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +355   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +148   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75</pre></code>                  </td>               </tr>            </table>            <br>            <hr width=100% size=1 color=silver>            <b>Version Information:</b>ÿMicrosoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1            </font>    </body></html><!-- [InvalidOperationException]: Could not find a base address that matches scheme https for the endpoint with binding WSHttpBinding. Registered base address schemes are [http].   at System.ServiceModel.ServiceHostBase.MakeAbsoluteUri(Uri relativeOrAbsoluteUri, Binding binding, UriSchemeKeyedCollection baseAddresses)   at System.ServiceModel.Description.ConfigLoader.LoadServiceDescription(ServiceHostBase host, ServiceDescription description, ServiceElement serviceElement, Action`1 addBaseAddress)   at System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader configLoader, ServiceDescription description, ServiceElement serviceSection)   at System.ServiceModel.ServiceHostBase.ApplyConfiguration()   at System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses)   at System.ServiceModel.ServiceHost.InitializeDescription(Type serviceType, UriSchemeKeyedCollection baseAddresses)   at System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses)   at System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(Type serviceType, Uri[] baseAddresses)   at System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses)   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.CreateService(String normalizedVirtualPath)   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String normalizedVirtualPath)   at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)[ServiceActivationException]: The service '/Service1.svc' cannot be activated due to an exception during compilation.  The exception message is: Could not find a base address that matches scheme https for the endpoint with binding WSHttpBinding. Registered base address schemes are [http]..   at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result)   at System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, String routeServiceVirtualPath, Boolean flowContext, Boolean ensureWFService)   at System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e)   at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)-->--.

錯誤的重要部分可能是:

Could not find a base address that matches scheme https for the endpoint with binding WSHttpBinding. Registered base address schemes are [http].

這是我的web.config文件:

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="Binding1">
          <security mode="TransportWithMessageCredential">
            <message clientCredentialType="UserName"/>
          </security>
        </binding>
      </wsHttpBinding>

    </bindings>
    <services>
      <service behaviorConfiguration="ServiceBehavior" name="AutoSenderWCFService.AutoSenderService">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="Binding1"
          contract="AutoSenderWCFService.IService1"></endpoint>
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />

      </service>
    </services>

    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceCredentials>

            <userNameAuthentication userNamePasswordValidationMode="Custom"
              customUserNamePasswordValidatorType="AutoSenderWCFService.MyValidator, AutoSenderWCFService"/>
            <serviceCertificate findValue="Michael-PC.pth.local" storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" />
          </serviceCredentials>

          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpsGetEnabled="true" httpGetEnabled="True"/>
          <!-- 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="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

我想要創建它,以便可以在本地計算機上對其進行調試,然后將其上傳到服務器並使用自認證證書運行。

同樣的問題。 帶有WCF錯誤的https:“找不到與方案https匹配的基地址”

此外,嘗試httpGetEnabled =“ False”和httpsGetEnabled =“ False”

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM