我如何调查WCF提供400错误的请求过得到什么? [英] How do I investigate WCF giving 400 bad request over GET?
问题描述
下面的WCF端点工作得很好用WCF测试客户端:
The following WCF endpoint works just fine with the WCF test client:
[OperationContract]
[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);
然而,当我试图导航到网址的http://本地主机/DigitalREST/XosAssets.svc/listflaggedassets/SEC?endpoint=superfan&pid=0&processCode=0&index=0&limit=20
我得到一个400错误的请求。
However, when I attempt to navigate to the URL http://localhost/DigitalREST/XosAssets.svc/listflaggedassets/SEC?endpoint=superfan&pid=0&processCode=0&index=0&limit=20
I get a 400 bad request.
我似乎无法找到任何方式来弄清楚为什么我得到一个错误的请求,并连接到IIS调试任何异常不破。
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
降这到你的app.config(来源登录从这个答案服用):
Drop this into your app.config (logging sources taken from this answer):
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true" >
<listeners>
<add name="xml"/>
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging">
<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="TraceLog.svclog" />
</sharedListeners>
</system.diagnostics>
然后,打开服务跟踪查看器的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.
您可能还需要检查在启用例外调试器。在Visual Studio中,转到调试 - >例外
,并检查是否有正确的框架进行检查。
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.
这篇关于我如何调查WCF提供400错误的请求过得到什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!