我必須在 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 關注
- 219 瀏覽
添加回答
舉報
0/150
提交
取消