WCF RESTful服务 - 如何调试?

时间:2021-10-31 19:35:23

I am starting out on a WCF project that has an underlying RESTful architecture to it. I have so far a Service Class and a Service Contract via an Interface in place. If I go to my Solution Explorer and right-click on the .svc file (Service Class) and View in Browser, I can view my Data Sources in a RESTful way, e.g. Addresses/ and /Employees/. But here's my problem, there are some Classes that can't be displayed, i.e. I get the "Internet Explorer cannot display the webpage" message. My question is, how can I debug through my code so I can find out where the problem is, i.e. so I won't be using 'View in Browser'. I don't want to create a complex Client (UI)... I would just like my Service to be accessible via the HTTP so when I type in say Service.svc/Employees, the Employees collection loads.

我开始在一个具有底层RESTful架构的WCF项目上。到目前为止,我已通过接口到位了服务类和服务合同。如果我转到我的解决方案资源管理器并右键单击.svc文件(服务类)和浏览器中的视图,我可以以RESTful方式查看我的数据源,例如地址/和/员工/。但这是我的问题,有一些无法显示的类,即我得到“Internet Explorer无法显示网页”消息。我的问题是,我如何通过我的代码调试,以便找出问题所在,即所以我不会使用“在浏览器中查看”。我不想创建一个复杂的客户端(UI)...我只想通过HTTP访问我的服务,所以当我输入说Service.svc / Employees时,Employees集合加载。

2 个解决方案

#1


Use Fiddler to interactively test your REST services.

使用Fiddler以交互方式测试您的REST服务。

#2


How complex does the client have to be in order to test your service?

客户必须有多复杂才能测试您的服务?

Consider that you will be asking other developers to use your service. If you can't even create a client to use it, then how do you expect them to be able to use it?

考虑您将要求其他开发人员使用您的服务。如果您甚至无法创建客户端来使用它,那么您希望它们如何能够使用它?

#1


Use Fiddler to interactively test your REST services.

使用Fiddler以交互方式测试您的REST服务。

#2


How complex does the client have to be in order to test your service?

客户必须有多复杂才能测试您的服务?

Consider that you will be asking other developers to use your service. If you can't even create a client to use it, then how do you expect them to be able to use it?

考虑您将要求其他开发人员使用您的服务。如果您甚至无法创建客户端来使用它,那么您希望它们如何能够使用它?