我必须在 XML 中调用一个使用 EPP(可扩展配置协议)的 Web API,并返回一个 XML 作为响应。我还需要使用证书来调用它,但是收到的响应为空。PHP 中只有一个示例代码可以工作。eppClient.php<?php require_once 'config.php';require_once 'eppFunctions.php';//Get XML variable via POST method $xmlStr = stripslashes(trim($_POST['xmlStr']));$response = send_epp_request($USER_CERTIFICATE_FILE, $EPP_SERVER_URL, $xmlStr);if(!$response === false){ //Show Server Response as XML header("Content-type: application/xml"); echo $response;}?>配置文件<?php//Server URL Address For Sending XML$EPP_SERVER_URL = "api.site.com/submit";//URL CERTIFICATE FILE$USER_CERTIFICATE_FILE = "";?>
2 回答
慕的地10843
TA贡献1785条经验 获得超8个赞
尝试这个。
string data = "{}";
WebRequest myReq = WebRequest.Create(url);
//set webreuqest properties e.g
//myReq.Method = "POST";
//myReq.ContentLength = lenght;
UTF8Encoding enc = new UTF8Encoding();
using (Stream ds = myReq.GetRequestStream())
{
ds.Write(enc.GetBytes(data), 0, data.Length);
}
using (WebResponse wr = myReq.GetResponse())
{
Stream receiveStream = wr.GetResponseStream();
using (StreamReader reader = new StreamReader(receiveStream, Encoding.UTF8))
{
string content = reader.ReadToEnd();
}
}
- 2 回答
- 0 关注
- 198 浏览
添加回答
举报
0/150
提交
取消