我添加了自己的@R_502_6268@服务行为来记录未处理的异常(下面的“ErrorHandling”),我正在使用MembershipProvider来获取服务凭据.这是我的完整system.serviceModel配置:
<system.serviceModel> <diagnostics wmiProviderEnabled="true"> <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" maxMessagesToLog="3000" maxSizeOfMessagetoLog="-1" /> </diagnostics> <extensions> <behaviorExtensions> <add name="ErrorHandling" type="MyCompany.MyProduct.Services.ErrorHandlerBehavior,MyCompany.MyProduct.Services" /> </behaviorExtensions> </extensions> <services> <service name="MyCompany.MyProduct.Services.applicationservice" behaviorConfiguration="MyProductServiceBehavior"> <endpoint bindingConfiguration="MyProductWsHttpBinding" binding="wsHttpBinding" contract="MyCompany.MyProduct.Services.Iapplicationservice" /> </service> <service name="MyCompany.MyProduct.Services.AccountService" behaviorConfiguration="MyProductServiceBehavior"> <endpoint bindingConfiguration="MyProductWsHttpBinding" binding="wsHttpBinding" contract="MyCompany.MyProduct.Services.IAccountService" /> </service> <service name="MyCompany.MyProduct.Services.InvoiceService" behaviorConfiguration="MyProductServiceBehavior"> <endpoint bindingConfiguration="MyProductWsHttpBinding" binding="wsHttpBinding" contract="MyCompany.MyProduct.Services.IInvoiceService" /> </service> <service name="MyCompany.MyProduct.Services.ReportService" behaviorConfiguration="MyProductServiceBehavior"> <endpoint bindingConfiguration="MyProductWsHttpBinding" binding="wsHttpBinding" contract="MyCompany.MyProduct.Services.IReportService" /> </service> <service name="MyCompany.MyProduct.Services.PaymentService" behaviorConfiguration="MyProductServiceBehavior"> <endpoint bindingConfiguration="MyProductWsHttpBinding" binding="wsHttpBinding" contract="MyCompany.MyProduct.Services.IPaymentService" /> </service> </services> <bindings> <wsHttpBinding> <binding name="MyProductWsHttpBinding"> <s@R_502_4395@ mode="Message"> <message clientCredentialType="UserName" establishS@R_502_4395@Context="true" negotiateServiceCredential="true" /> </s@R_502_4395@> </binding> </wsHttpBinding> </bindings> <behaviors> <serviceBehaviors> <behavior name="MyProductServiceBehavior"> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="true" /> <serviceCredentials> <serviceCertificate findValue="MyProductServices" storeLocation="CurrentUser" storeName="My" x509FindType="FindBySubjectName" /> <userNameAuthentication userNamePasswordValidationMode="MembershipProvider" membershipProviderName="AspNetsqlMembershipProvider" /> </serviceCredentials> <ErrorHandling /> <serviceS@R_502_4395@Audit auditLogLocation="Application" suppressAuditFailure="false" serviceAuthorizationAuditLevel="SuccessOrFailure" messageAuthenticationAuditLevel="SuccessOrFailure" /> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" /> </system.serviceModel>
您可以看到我还启用了安全审核,但事件日志中没有显示任何内容,除了显示消息日志已打开的消息.因此,当客户端调用该操作时,它似乎永远不会进入身份验证阶段.
我也启用了跟踪如下:
<system.diagnostics> <sources> <source name="System.ServiceModel" switchValue="All" propagateActivity="true" > <listeners> <add name="xml"/> </listeners> </source> <source name="System.ServiceModel.MessageLogging" switchValue="All"> <listeners> <add name="xml"/> </listeners> </source> <source name="myUserTraceSource" switchValue="@R_842_4045@ion,ActivityTracing"> <listeners> <add name="xml"/> </listeners> </source> </sources> <sharedListeners> <add name="xml" type="System.Diagnostics.XmlWriterTraceListener" initializeData="C:\Users\Public\Documents\services.svclog" /> </sharedListeners> </system.diagnostics>
当客户端调用主服务中的主操作时,它会收到一条带有以下消息的协议异常:
内容类型text / html; charset =响应消息的UTF-8与绑定的内容类型(application / soap xml; charset = utf-8)不匹配.如果使用@R_502_6268@编码器,请确保正确实现IsContentTypeSupported方法.响应的前1024个字节是:’#content {FONT-SIZE:0.7em; PADDING-BottOM:2em; MARGIN-LEFT:30px} BODY {MARGIN-TOP:0px; MARGIN-LEFT:0px;颜色:#000000; FONT-FAMILY:Verdana;背景颜色:白色} P {MARGIN-TOP:0px; MARGIN-BottOM:12px;颜色:#000000; FONT-FAMILY:Verdana} PRE {BORDER-RIGHT:#f0f0e0 1px solid; PADDING-RIGHT:5px; BORDER-TOP:#f0f0e0 1px solid; MARGIN-TOP:-5px; PADDING-LEFT:5px; FONT-SIZE:1.2em; PADDING-BottOM:5px; BORDER-LEFT:#f0f0e0 1px solid; PADDING-TOP:5px; BORDER-BottOM:#f0f0e0 1px solid; FONT-FAMILY:Courier New;背景颜色:#e5e5cc} .heading1 {MARGIN-TOP:0px; PADDING-LEFT:15px; FONT-WEIGHT:正常; FONT-SIZE:26px; MARGIN-BottOM:0px; PADDING-BottOM:3px; MARGIN-LEFT:-30px;宽度:100%;颜色:#ffffff; PADDING-TOP:10px; FONT-FAMILY:Tahoma; BACKGROUND-COLOR:#003366} .intro {MARGIN-LEFT:-15px} applicationservice Service’.
当您浏览.svc文件时,您看到的元数据页面的html是什么.因此,似乎服务正在返回该页面作为对操作的响应.
查看services.svclog讲述了同样的故事,实际上日志格式错误是xml,因为这个响应包含在其中而没有标记被转义.跟踪中没有任何有用的信息.
服务器上没有抛出异常,日志什么都没有.这一切都适用于我设置的另一台服务器上的IIS6,只是为了测试它,错误记录也在那里工作.
哪些工具和技术可以帮助我弄清楚根本问题是什么?
更新:这是来自服务器端跟踪的svclog,用于来自新生成的控制台应用客户端的单个请求(擦除以删除个人信息),注意它在最后被截断的方式:
http://pastebin.com/mksL0FFY
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。