我正在开发一个.Net客户端来从oData服务中检索数据。我的客户使用System.Data.Services.Client.DataServiceContext。如何通过SSL跟踪.Net DataServiceContext中的oData请求?
我想看到实际的oData请求发送到服务器。服务器使用SSL连接,并且对服务器的请求不容易被嗅探。我试图用Burp来做到这一点。我添加了一个SendingRequest EventHandler并设置了Request.Proxy属性。但是,这给出了一个例外:
底层连接已关闭:无法建立SSL/TLS安全通道的信任关系。
Wireshark只显示加密数据。
另外,我可以联系OData提供商的服务器日志,但这需要一些时间。我正在寻找一个瞬间的痕迹。
以下是使用Microsoft Northwind oData服务的示例客户端。
- 创建一个类库;
- 添加服务推荐到Northwind;
- 创建一个类oDataClient;
- 添加方法
Customers()
; - 创建测试项目;
- 在其中创建一个单元测试
Customers()
; - 运行测试。
方法:
public class oDataClient
{
public void Customers()
{
{
var context = new Northwind.NorthwindEntities(new System.Uri("http://services.odata.org/V3/Northwind/Northwind.svc/"));
var customers = from c in context.Customers
where c.CompanyName.StartsWith("A")
select c;
int count = customers.Count();
}
}
}
测试:
[TestMethod()]
public void CustomersTest()
{
oDataClient target = new oDataClient();
target.Customers();
}