以下WCF端点适用于WCF测试客户端:
[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://localhost/DigitalREST/XosAssets.svc/listflaggedassets/SEC?endpoint=superfan&pid=0&processCode=0&index=0&limit=20
时,我收到400错误请求。
我似乎找不到任何方法来弄清楚为什么我收到了错误的请求,并且附加到IIS进行调试并没有中断任何异常。
如何调查错误请求的原因?
答案 0 :(得分:6)
您可以启用跟踪并使用Service Trace Viewer
将其放入app.config(记录来源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>
然后,在Service Trace Viewer中打开TraceLog.svclog。它可能无法确切地告诉您发生了什么,但它将提供有关流量和异常本身的详细信息。
您可能还想检查调试器中启用的例外情况。在Visual Studio中,转到Debug -> Exceptions
并检查是否已选中正确的框架。
答案 1 :(得分:0)
答案 2 :(得分:0)
我遇到的一个原因是:
我试图请求使用带有查询字符串的URL,但httpbinding在配置文件中没有到位,结果我收到了400-Bad请求错误。
答案 3 :(得分:0)
您可以尝试使用fiddler并尝试svcTracer,它可以为您提供大量的调试信息,您也可以在服务器上使用includeExceptionDetailInFaults=true
标志但重要的是要知道它并不总是正确的发送如果客户是外部实体,则特别向客户提供此信息。有了这个警告,下面是提示如何使用它。
<serviceBehaviors>
<behavior name="ServiceBehavior">
....
<serviceDebug includeExceptionDetailInFaults="true" />
....
</behavior>
</serviceBehaviors>
快乐的调试:)