嘿,夥計們,我開始一個EPP客戶端,它只會返回來自服務器的問候,即使我嘗試發送我的登錄命令。EPP總是返回問候
這是我的代碼,它有什麼問題?
using (var _tcpClient = new TcpClient(_endpoint.Host, _endpoint.Port))
{
using (var sslStream = new SslStream(_tcpClient.GetStream(), false, ValidateServerCertificate))
{
sslStream.AuthenticateAsClient(_endpoint.Host);
XmlDocument xdoc = new XmlDocument();
xdoc.LoadXml(requestData);
xdoc.Save("C:/request.xml");
string data = xdoc.InnerXml;
byte[] bytedata = Encoding.UTF8.GetBytes(data);
//Get the request stream.
sslStream.Write(bytedata, 0, bytedata.Length);
// Write the data to the request stream.
sslStream.Flush();
var response = ReadMessage(sslStream);
XResponse = XDocument.Parse(response);
XResponse.Save("C:/response.xml");
}
}
return XResponse;
}
private string ReadMessage(SslStream sslStream)
{
// The first four bytes will be the the content length as a network order (big-endian) 32-bit number.
var lengthBytes = new byte[4];
sslStream.Read(lengthBytes, 0, 4);
Array.Reverse(lengthBytes);
var length = BitConverter.ToInt32(lengthBytes, 0) - 4;
// Create a byte array of the correct size for the response.
var messageBytes = new byte[length];
var returned = 0;
while (returned != length)
{
returned += sslStream.Read(messageBytes, 0, length);
}
return Encoding.UTF8.GetString(messageBytes);
}
即使我不寫任何與ssl流它仍然返回問候。
如果你們可以指出我在正確的方向,將不勝感激。
這個!!! 我最終確實得到它的工作,但忘了更新問題,所以謝謝你:) – CKG