What is the best way to diagnose a WCF service when an operation returns an html meta page?

I have a WCF service application (wsHttpBinding) hosted in IIS7.5 (.NET 4), and I can navigate the browser .svc file and the metadata page is displayed successfully, and clients can be generated from wsdl.

I have added my own custom service behavior for reporting unhandled exceptions (below "ErrorHandling"), and I am using MemberhipProvider for the service credentials. Here is my complete system.serviceModel configuration:

<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"> <security mode="Message"> <message clientCredentialType="UserName" establishSecurityContext="true" negotiateServiceCredential="true" /> </security> </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 /> <serviceSecurityAudit auditLogLocation="Application" suppressAuditFailure="false" serviceAuthorizationAuditLevel="SuccessOrFailure" messageAuthenticationAuditLevel="SuccessOrFailure" /> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" /> </system.serviceModel> 

You can see that I also turned on security checking , but nothing appears in the event log except for the message that message logging is turned on . Therefore, when a client invokes an operation, it never enters the authentication phase.

I also have a trace:

 <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="Information, 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> 

When the client invokes the main operation in the primary service, it receives a protocol exception with this message:

Content Type text / html; charset = UTF-8 of the response message does not match the content type of the binding (application / soap + xml; charset = utf-8). If you use a custom encoder, make sure that the IsContentTypeSupported method is implemented correctly. The first 1024 bytes of the response were: "#content {FONT-SIZE: 0.7em; PADDING-BOTTOM: 2em; MARGIN-LEFT: 30px} BODY {MARGIN-TOP: 0px; MARGIN-LEFT: 0px; COLOR: # 000000; FONT- FAMILY: Verdana; BACKGROUND-COLOR: white} P {MARGIN-TOP: 0px; MARGIN-BOTTOM: 12px; COLOR: # 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; BACKGROUND-COLOR: # e5e5cc} .heading1 {MARGIN-TOP: 0px; PADDING-LEFT: 15px; FONT-WEIGHT: normal; FONT-WEIGHT: FONT-WEIGHT: normal 26px; MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 3px; MARGIN-LEFT: -30px; WIDTH: 100%; COLOR: #ffffff; PADDING-TOP: 10px; FONT-FAMILY: Tahoma; BACKGROUND-COLOR: # 003366 .intro {MARGIN-LEFT: -15px} ApplicationService.

What is the html for the metadata page that you see when viewing the .svc file. So it seems that the service is returning this page as a response to the operation.

Viewing services.svclog tells the same story, in fact the log has incorrect xml, because this answer is included in it without the tags being escaped. There is no useful information that this has always been the case.

There are no exceptions on the server; the logs have nothing. It all works on IIS6 on another server that I configure to check it, and the error log also works there.

What tools and methods will help me figure out what the root problem is?

UPDATE: Here is an example of svclog from server side tracing executed for a single request from a newly created console application client (cleared to remove personal information), note how it is truncated at the end: http://pastebin.com/mksL0FFY

+4
source share
2 answers

Check the rules for rewriting URLs in IIS for a site. If one of them redirects, this may result in clients receiving a metadata page as a response to the operation. I have seen this before, it can be misleading.

0
source

Since the event log is empty, you must check the IIS log to make sure the call succeeds. I got similar error messages and the problem is usually related to permissions. Ensure that the accounts used for the application pool and website have sufficient privileges. I think you will see an event log message if there was a problem with authentication with the membership provider. Also, try calling the method using the WcfTestClient application so that you can see that the XML is passed in any way.

+1
source

Source: https://habr.com/ru/post/1369202/


All Articles