如何使用SSL Web服务记录/跟踪WCF Restful [英] How to log / trace a WCF Restful with SSL webservice
问题描述
我使用SSL自托管证书创建了wcf rest。我已经在我的本地系统(.i.e Intranet)中部署了我的服务。
我已经在我的提琴工具中测试过了。但我想检查我的消息是否安全。所以我在配置文件中添加了跟踪和登录,如下所示。
问题是请求和响应,或者没有任何内容写入我的日志。 />
< system.web>
< compilation debug = true targetFramework = 4.0 />
< / system.web >
< system.serviceModel>
< services>
< service name = PracticeWcfService1.Service1 >
< endpoint address = RestType behaviorConfiguration = PracticeWcfService1.Service1ehaviour binding = webHttpBinding
contract = PracticeWcfService1.IService1 name = RestClient >
< identity>
< dns value = localhost />
< / identity >
< / endpoint >
< endpoint address = RestTypeWithSecure behaviorConfiguration = PracticeWcfService1.Service1ehaviour binding = webHttpBinding
contract = PracticeWcfService1.IService1 name = RestClientWithSecure bindingConfiguration = PracticeWcfService1.Services.ClientServicesEndpointB inding >
< identity>
< dns value = localhost />
< / identity >
< / endpoint >
< endpoint address = SoapType binding = basicHttpBinding contract = PracticeWcfService1.IService1 name = SoapClient < span class =code-keyword>>
< identity>
< dns value = localhost />
< / identity >
< / endpoint >
< endpoint address = mex binding = mexHttpBinding contract = IMetadataExchange > < / 端点 >
< host>
< baseAddresses>
< add baseAddress = http:// localhost:33333 / Service1.svc />
< / baseAddresses >
< / host >
< / service >
< / 服务 >
< bindings>
< webHttpBinding>
< binding name = PracticeWcfService1.Services.ClientServicesEndpointBinding >
< security mode = 运输 >
< / security >
< / 绑定 >
< / webHttpBinding >
< / bindings >
< behavior>
< endpointBehaviors>
< behavior name = PracticeWcfService1.Service1ehaviour >
< webHttp />
< / 行为 >
< / endpointBehaviors >
< serviceBehaviors>
< behavior>
<! - 为了避免公开元数据信息,设置 值以下 false 和删除上面的元数据端点 - >
< serviceMetadata httpGetEnabled = true httpsGetEnabled = true />
<! - 要接收 以进行调试,将值设置为 true 。在部署之前设置为 false 以避免泄露异常信息 - >
< serviceDebug includeExceptionDetailInFaults = true />
< serviceThrottling maxConcurrentCalls = 500 maxConcurrentInstances = 250 />
< / 行为 >
< / serviceBehaviors >
< / 行为 >
< serviceHostingEnvironment multipleSiteBindingsEnabled = true />
< diagnostics>
< messageLogging logEntireMessage = true
logMessagesAtServiceLevel = true
logMessagesAtTransportLevel = true
maxMessagesToLog = 200000
maxSizeOfMessageToLog = 200000 />
< / 诊断 >
< / system.serviceModel >
< system.diagnostics>
< sources>
< source name = System.ServiceModel switchValue = 全部
propagateActivity = true >
< listeners>
< add type = System.Diagnostics.DefaultTraceListener name = 默认 >
< filter type = />
< / add >
< add name = ServiceModelTraceListener >
< filter type = />
< / add >
< / 听众 >
< / source >
< source name = System.ServiceModel.MessageLogging switchValue = 所有 >
< listeners>
< add type = System.Diagnostics.DefaultTraceListener name = 默认 >
< filter type = />
< / add >
< add name = ServiceModelMessageLoggingListener >
< filter type = />
< / add >
< / 听众 >
< / source >
< / 来源 >
< sharedListeners>
< add initializeData = C:\ Users \sdanda \Downloads\PracticeWcfService1 \ PracticeWcfService1 \Messages.svclog
type = System.Diagnostics.XmlWriterTraceListener,System, Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089
name = ServiceModelMessageLoggingListener traceOutputOptions = 时间戳 >
< filter type = />
< / add >
< add initializeData = C:\ Users \sdanda\Downloads\PracticeWcfService1 \ PRracticeWcfService1 \Tracelog.svclog
type = System.Diagnostics.XmlWriterTraceListener, System,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089
name = ServiceModelTraceListener traceOutputOptions = 时间戳 >
< filter type = />
< / add >
< / sharedListeners >
< trace autoflush = true />
< / system.diagnostics >
< system.webServer>
< modules runAllManagedModulesForAllRequests = true />
< directoryBrowse enabled = true />
< / system.webServer >
我已经通过将mexHttpBinding更改为mexHttpsBinding和HttpsEnabled = true标签进行测试,但没有用。
请帮助我如何才能看到天气信息安全与否?否则有没有办法检查加密的消息是否发生?
先谢谢
< blockquote>这可以帮助你 -
http:// dotnetmentors .com / wcf / wcf-message-level-security-by-example.aspx [ ^ ]
I have created wcf rest with SSL self hosted certificate. I have deployed my service in my local system (.i.e Intranet).
I have tested in my fiddler tool. But i want to check wheather my messages going securely or not. So that i have add tracing and logging in my config file as shown in below.
Problem is the requests and responces or anything is not writing into my logs.
<system.web>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
<system.serviceModel>
<services>
<service name="PracticeWcfService1.Service1">
<endpoint address="RestType" behaviorConfiguration="PracticeWcfService1.Service1ehaviour" binding="webHttpBinding"
contract="PracticeWcfService1.IService1" name="RestClient">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="RestTypeWithSecure" behaviorConfiguration="PracticeWcfService1.Service1ehaviour" binding="webHttpBinding"
contract="PracticeWcfService1.IService1" name="RestClientWithSecure" bindingConfiguration="PracticeWcfService1.Services.ClientServicesEndpointBinding">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="SoapType" binding="basicHttpBinding" contract="PracticeWcfService1.IService1" name="SoapClient">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
<host>
<baseAddresses>
<add baseAddress="http://localhost:33333/Service1.svc" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="PracticeWcfService1.Services.ClientServicesEndpointBinding">
<security mode="Transport">
</security>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="PracticeWcfService1.Service1ehaviour">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="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" />
<serviceThrottling maxConcurrentCalls="500" maxConcurrentInstances="250"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<diagnostics>
<messageLogging logEntireMessage="true"
logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="true"
maxMessagesToLog="200000"
maxSizeOfMessageToLog="200000"/>
</diagnostics>
</system.serviceModel>
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="All"
propagateActivity="true">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="ServiceModelTraceListener">
<filter type="" />
</add>
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging" switchValue="All">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add name="ServiceModelMessageLoggingListener">
<filter type="" />
</add>
</listeners>
</source>
</sources>
<sharedListeners>
<add initializeData="C:\Users\sdanda\Downloads\PracticeWcfService1\PracticeWcfService1\Messages.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
<add initializeData="C:\Users\sdanda\Downloads\PracticeWcfService1\PracticeWcfService1\Tracelog.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
</sharedListeners>
<trace autoflush="true" />
</system.diagnostics>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<directoryBrowse enabled="true" />
</system.webServer>
I have tested by changing the mexHttpBinding to mexHttpsBinding and HttpsEnabled=true tags, but no use.
Please help me how can i see the weather my messages going securely or not?? otherwise is there any way to check the messages going with encrypted or not??
Thanks in Advance
This may help you-
http://dotnetmentors.com/wcf/wcf-message-level-security-by-example.aspx[^]
这篇关于如何使用SSL Web服务记录/跟踪WCF Restful的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!