KallDrexx KallDrexx - 8 months ago 53
C# Question

How do I investigate WCF giving 400 bad request over GET?

The following WCF endpoint works just fine with the WCF test client:

[WebGet(ResponseFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "listflaggedassets/{platform}?endpoint={endpoint}&pid={portalid}&processCode={processCode}&index={index}&limit={limit}")]
AssetList ListFlaggedAssets(short processCode, string platform, string endpoint = "null", string portalId = "null", int index = 0, int limit = 12);

However, when I attempt to navigate to the URL
I get a 400 bad request.

I can't seem to find any way to figure out WHY i'm getting a bad request, and attaching to IIS for debugging doesn't break on any exceptions.

How can I investigate the cause of a bad request?


You could enable tracing and use Service Trace Viewer

Drop this into your app.config (logging sources taken from this answer):

      <source name="System.ServiceModel"
              switchValue="Information, ActivityTracing"
              propagateActivity="true" >
          <add name="xml"/>
      <source name="System.ServiceModel.MessageLogging">
          <add name="xml"/>
      <source name="myUserTraceSource"
              switchValue="Information, ActivityTracing">
          <add name="xml"/>
      <add name="xml"
           initializeData="TraceLog.svclog" />

Then, open the TraceLog.svclog in Service Trace Viewer. It may not tell you exactly what's going on, but it will provide details about the traffic and the exception itself.

You may also want to check the exceptions you have enabled in the debugger. In Visual Studio, go to Debug -> Exceptions and check that you have the correct framework checked.