WCF服务未通过https从邮递员中击中 [英] WCF Service not hitting from postman over https

查看:52
本文介绍了WCF服务未通过https从邮递员中击中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在添加SSL证书邮递员查询之前.但是,当我添加SSL证书时,邮递员的请求不起作用.我已经附上了邮递员要求的文件,以下是我的webConfig文件.它给出错误400未找到.

 <?xml version ="1.0" encoding ="utf-8"?><配置>< 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;初始目录= CommandControl2.3;用户ID = sa; Password = smarti123#"/></connectionStrings>< appSettings><添加key ="appVersion"值="15"/><添加key ="appCode" value ="1.2.3"/><添加key ="appUpdatePriority" value ="1"/></appSettings>< system.web>< compilation debug ="true" targetFramework ="4.0"/></system.web>< system.serviceModel><绑定/><客户/>< serviceHostingEnvironment multipleSiteBindingsEnabled ="True"/><服务>< service behaviorConfiguration =默认" name ="SmartTrack.CMSWebService"><端点地址=" behaviorConfiguration ="webBehavior" binding ="webHttpBinding" contract ="SmartTrack.ISmartTrack"/><端点地址="mex" binding ="mexHttpBinding" contract ="IMetadataExchange"/></service></services><行为>< endpointBehaviors>< behavior name ="webBehavior">< webHttp helpEnabled ="true"/></行为></endpointBehaviors>< serviceBehaviors><行为名称=默认"><!-为避免泄露元数据信息,请在部署前将以下值设置为false.< serviceMetadata httpGetEnabled ="true"/></行为><行为名称=">< serviceMetadata httpGetEnabled ="true" httpsGetEnabled ="true"/>< serviceDebug includeExceptionDetailInFaults ="true"/><服务授权serviceAuthorizationManagerType="WcfWebHttpIISHostingSample.RestAuthorizationManager,WcfWebHttpIISHostingSample"/></行为></serviceBehaviors></行为></system.serviceModel>< system.webServer>< modules runAllManagedModulesForAllRequests ="true"/>< directoryBrowse enabled ="true"/></system.webServer>< applicationSettings>< SmartTrack.Properties.Settings>< setting name ="SYSTEM_LOG" serializeAs ="String"><值>真</值></setting>< setting name ="TRANSACTION_LOG" serializeAs ="String"><值>真</值></setting>< setting name ="COMMAND_LOG" serializeAs ="String"><值>真</值></setting>< setting name ="EXCEPTION_LOG" serializeAs ="String"><值>真</值></setting>< setting name ="ERROR_LOG" serializeAs ="String"><值>真</值></setting>< setting name ="CONFIG_LOGLEVEL" serializeAs ="String"><值> 0</值></setting>< setting name ="CONFIG_COMPONENT" serializeAs ="String"><值> 0</值></setting>< setting name ="LogPath" serializeAs ="String">< value> C:\ ServiceSmartTrack</value></setting></SmartTrack.Properties.Settings>< CMSWebService.Properties.Settings>< setting name ="SYSTEM_LOG" serializeAs ="String"><值>真</值></setting>< setting name ="TRANSACTION_LOG" serializeAs ="String"><值>真</值></setting>< setting name ="COMMAND_LOG" serializeAs ="String"><值>真</值></setting>< setting name ="EXCEPTION_LOG" serializeAs ="String"><值>真</值></setting>< setting name ="ERROR_LOG" serializeAs ="String"><值>真</值></setting>< setting name ="CONFIG_LOGLEVEL" serializeAs ="String"><值> 0</值></setting>< setting name ="CONFIG_COMPONENT" serializeAs ="String"><值> 0</值></setting>< setting name ="LogPath" serializeAs ="String">< value> C:\ ServiceSmartTrack</value></setting></CMSWebService.Properties.Settings></applicationSettings></configuration> 

解决方案

您需要配置https终结点,然后添加https协议并在IIS中指定https证书.

顺便说一下,我需要在IIS中配置https/http绑定基地址.
https://docs.microsoft.com/zh-cn/dotnet/framework/wcf/feature-details/how-to-configure-an-iis-hosted-wcf-service-with-ssl
随时让我知道是否有什么可以帮助您的.

Before adding SSL certificate postman query is hitting. But when i added SSL certificate, Postman request is not working. I have attached file of postman request and following is my webConfig file. It is giving Error 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>

解决方案

You need to configure the https endpoint, and then add the https protocol and specify the https certificate in IIS.
https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-configure-an-iis-hosted-wcf-service-with-ssl
Here is my configuration file whose http/https endpoint are all configurated, wish it is useful to you.

       <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>

Result.
By the way, I need to configure https/http binding base address in IIS.
https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-configure-an-iis-hosted-wcf-service-with-ssl
Feel free to let me know if there is anything I can help with.

这篇关于WCF服务未通过https从邮递员中击中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆