以下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);
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试导航到URL时,http://localhost/DigitalREST/XosAssets.svc/listflaggedassets/SEC?endpoint=superfan&pid=0&processCode=0&index=0&limit=20我收到400错误请求.
我似乎无法找到任何方法来弄清楚为什么我收到一个错误的请求,并附加到IIS进行调试不会中断任何异常.
如何调查错误请求的原因?
您可以启用跟踪并使用服务跟踪查看器
将其放入app.config(记录从此答案中获取的源):
<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>
Run Code Online (Sandbox Code Playgroud)
然后,在Service Trace Viewer中打开TraceLog.svclog.它可能无法准确地告诉您发生了什么,但它将提供有关流量和异常本身的详细信息.
您可能还想检查在调试器中启用的异常.在Visual Studio中,转到Debug -> Exceptions并检查是否已选中正确的框架.