在添加SSL证书之前,postman查询正在命中。但是当我添加SSL证书时,Postman请求无效。我附上邮递员请求文件,以下是我的webConfig文件。它给出了错误400 Not Found。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="SmartTrack.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="CMSWebService.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<connectionStrings>
<add name="SmartTrack.Properties.Settings.connectionstring" connectionString="Data Source=localhost;Initial Catalog=CommandControl2.3;User ID=sa;Password=smarti123#" />
</connectionStrings>
<appSettings>
<add key="appVersion" value="15" />
<add key="appCode" value="1.2.3" />
<add key="appUpdatePriority" value="1" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings />
<client />
<serviceHostingEnvironment multipleSiteBindingsEnabled="True" />
<services>
<service behaviorConfiguration="Default" name="SmartTrack.CMSWebService">
<endpoint address="" behaviorConfiguration="webBehavior" binding="webHttpBinding" contract="SmartTrack.ISmartTrack" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="webBehavior">
<webHttp helpEnabled="true" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="Default">
<!-- To avoid disclosing metadata information, set the value below to false before deployment -->
<serviceMetadata httpGetEnabled="true"/>
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceAuthorization
serviceAuthorizationManagerType
=" WcfWebHttpIISHostingSample.RestAuthorizationManager, WcfWebHttpIISHostingSample"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="true" />
</system.webServer>
<applicationSettings>
<SmartTrack.Properties.Settings>
<setting name="SYSTEM_LOG" serializeAs="String">
<value>True</value>
</setting>
<setting name="TRANSACTION_LOG" serializeAs="String">
<value>True</value>
</setting>
<setting name="COMMAND_LOG" serializeAs="String">
<value>True</value>
</setting>
<setting name="EXCEPTION_LOG" serializeAs="String">
<value>True</value>
</setting>
<setting name="ERROR_LOG" serializeAs="String">
<value>True</value>
</setting>
<setting name="CONFIG_LOGLEVEL" serializeAs="String">
<value>0</value>
</setting>
<setting name="CONFIG_COMPONENT" serializeAs="String">
<value>0</value>
</setting>
<setting name="LogPath" serializeAs="String">
<value>C:\ServiceSmartTrack</value>
</setting>
</SmartTrack.Properties.Settings>
<CMSWebService.Properties.Settings>
<setting name="SYSTEM_LOG" serializeAs="String">
<value>True</value>
</setting>
<setting name="TRANSACTION_LOG" serializeAs="String">
<value>True</value>
</setting>
<setting name="COMMAND_LOG" serializeAs="String">
<value>True</value>
</setting>
<setting name="EXCEPTION_LOG" serializeAs="String">
<value>True</value>
</setting>
<setting name="ERROR_LOG" serializeAs="String">
<value>True</value>
</setting>
<setting name="CONFIG_LOGLEVEL" serializeAs="String">
<value>0</value>
</setting>
<setting name="CONFIG_COMPONENT" serializeAs="String">
<value>0</value>
</setting>
<setting name="LogPath" serializeAs="String">
<value>C:\ServiceSmartTrack</value>
</setting>
</CMSWebService.Properties.Settings>
</applicationSettings>
</configuration>
您需要配置https端点,然后添加https协议并在IIS中指定https证书。 https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-configure-an-iis-hosted-wcf-service-with-ssl 这是我的配置文件,其http / https端点都已配置,希望它对您有用。
<system.serviceModel>
<services>
<!--http, https are all configurated-->
<service behaviorConfiguration="mybehavior" name="WcfService1.Service1"> <!--http, https are all configurated-->
<endpoint address="" binding="webHttpBinding" contract="WcfService1.IService1" behaviorConfiguration="webbev" bindingConfiguration="mybinding"></endpoint>
<endpoint address="" binding="webHttpBinding" contract="WcfService1.IService1" behaviorConfiguration="webbev" bindingConfiguration="com"></endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"></endpoint>
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="mybinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" sendTimeout="00:10:00" receiveTimeout="00:10:00">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" />
<security mode="Transport">
<transport clientCredentialType="None"></transport>
</security>
</binding>
<binding name="com">
<security mode="None"></security>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="mybehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="webbev">
<webHttp />
</behavior>
</endpointBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> </system.serviceModel>
结果。 顺便说一句,我需要在IIS中配置https / http绑定基址。 https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-configure-an-iis-hosted-wcf-service-with-ssl 如果有什么我可以帮忙,请随时告诉我。