发送XML请求并获取响应

时间:2013-07-23 20:15:48

标签: xml request response

我一直在努力解决这个简单的问题。

我正在尝试向此网站发布XML请求,但我甚至不知道从哪里开始。首先应该使用哪种软件?

XML框架在doc(http://profiles.catalyst.harvard.edu/docs/ProfilesRNS_DisambiguationEngine.pdf

中描述

我的问题更多的是在哪里输入?

由于

罗曼

1 个答案:

答案 0 :(得分:0)

这就是所谓的RPC-XML请求。您将按照文档指定的方式格式化Web请求。你如何进行取决于你将使用什么语言。在C#中,你会做这样的事情:

// create a web request that'll post some xml content to a web service
string url = "http://profiles.catalyst.harvard.edu/services/GetPMIDs/default.asp";
var request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.ContentType = "text/xml";

// set the content length based on the data you are passing through the
// web call
var data = Encoding.UTF8.GetBytes("<generated xml here as a string>");
request.ContentLength = data.Length;

// write the data to the request stream before you actually make the 
// the request.
using (var stream = request.GetRequestStream())
    stream.Write(data, 0, data.Length);

// actually make the web request and get the response.
// this will hold the response from the request when it completes
var response = request.GetResponse().GetResponseStream();