我有一个任务要调用我们使用C#和ASP服务,而我在此任务中所拥有的只是 link ,而不是.asmx或WSDL,它是一个正常链接,例如https://www.normallink.com
我使用Postman Extension尝试了此链接,它带来了JSON数据,因此如何使用ASP
检索这些数据这是Postman的JSON数据的示例
"data": [
{
"id": "516",
"name": "xyz"
},
我认为这就是您要寻找的:
String jsonData = ...;
WebRequest request = WebRequest.Create("http://www.mywebservice.com/");
request.ContentType = "application/json";
request.Method = "POST";
using (Stream postStream = request.GetRequestStream())
{
using (StreamWriter postWriter = new StreamWriter(postStream))
postWriter.Write(jsonData);
}
WebResponse response = request.GetResponse();
String responseContent;
using (Stream stream = response.GetResponseStream())
{
using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
responseContent = reader.ReadToEnd();
}