【问题标题】:Send XML request and get response back发送 XML 请求并返回响应
【发布时间】:2013-07-23 20:15:48
【问题描述】:

我一直在为这个简单的问题苦苦挣扎。

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

文档中描述了 XML 框架 (http://profiles.catalyst.harvard.edu/docs/ProfilesRNS_DisambiguationEngine.pdf)

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

谢谢

罗曼

【问题讨论】:

    标签: xml request response


    【解决方案1】:

    这就是所谓的 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();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-03-11
      • 2011-06-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-29
      • 1970-01-01
      相关资源
      最近更新 更多