c# - Odata 连接服务 - 如何使用它?
问题描述
我目前正在尝试制作一个虚拟控制台应用程序,以了解 AX Web API 的工作原理。
我将我的 odata webservice 添加为连接服务,并且从那里不确定我如何在我的 main 中引用它或对服务进行任何 get 调用。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using Microsoft.Data.OData;
using System.IO;
using System.Xml;
namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://10.51.32.14:8101/DynamicsAx/Services/ODataQueryService/Invent");
request.Method = "GET";
request.ContentType = "application/x-www-form-urlencoded";
//request.UseDefaultCredentials = true;
//request.PreAuthenticate = true;
request.Credentials = new NetworkCredential("admin_nc_keer", "C^Reup-rK)EH1j");
//request.Credentials = CredentialCache.DefaultCredentials;
try
{
using (WebResponse response = request.GetResponse())
{
using (Stream stream = response.GetResponseStream())
{
XmlTextReader reader = new XmlTextReader(stream);
Console.WriteLine(" {0}={1}", reader.Name, reader.Value);
}
}
}
catch(WebException e)
{
if (e.Status == WebExceptionStatus.Timeout)
{
Console.WriteLine("Timeout!");
}
else throw;
}
Console.WriteLine("End!");
Console.ReadLine();
}
}
}
什么都不返回...
没有为 odata 数据定义容器类型,而是一个内容类型,即
<content type="application/xml">
解决方案
推荐阅读
- discord.js - Discord检查是否存在mentioend频道
- android - Android Room 数据库 LiveData 响应来自两个不同表的数据
- python-3.x - 如何使用bs4提取html表格
- apache-spark - 通过 json 键拆分 spark 数据帧行以创建新的数据帧输出
- ios - Swift - 是否可以通过单击按钮移动到 tableview 中的下一个单元格?
- laravel - 如何影响自定义 Request 类的执行优先级?
- javascript - Vue - 包裹找不到模块
- heroku - 我想使用枕头模块,但是
- php - HTML - 将静态行添加到带有输入字段的表中
- python - Python中的复数id