- Created a standard function to send XML-RPC requests, which logs them like we do for other types of HTTP activity.

- Changed OpenProfileClient to use the new XML-RPC sending function
- Improved logging in WebUtil
This commit is contained in:
Oren Hurvitz
2014-04-24 14:21:05 +03:00
parent e8a2eff2e8
commit bc06db3df4
4 changed files with 146 additions and 139 deletions

View File

@@ -35,7 +35,6 @@ using System.Reflection;
using System.Text;
using System.Xml;
using log4net;
using Nwc.XmlRpc;
using OpenMetaverse;
using OpenSim.Framework;
@@ -79,7 +78,12 @@ namespace OpenSim.Services.UserProfilesService
Hashtable ReqHash = new Hashtable();
ReqHash["avatar_id"] = props.UserId.ToString();
Hashtable profileData = GenericXMLRPCRequest(ReqHash, "avatar_properties_request", m_serverURI);
Hashtable profileData = XMLRPCRequester.SendRequest(ReqHash, "avatar_properties_request", m_serverURI);
if (profileData == null)
return false;
if (!profileData.ContainsKey("data"))
return false;
ArrayList dataArray = (ArrayList)profileData["data"];
@@ -128,66 +132,5 @@ namespace OpenSim.Services.UserProfilesService
return true;
}
private Hashtable GenericXMLRPCRequest(Hashtable ReqParams, string method, string server)
{
ArrayList SendParams = new ArrayList();
SendParams.Add(ReqParams);
XmlRpcResponse Resp;
try
{
XmlRpcRequest Req = new XmlRpcRequest(method, SendParams);
Resp = Req.Send(server, 30000);
}
catch (WebException ex)
{
m_log.ErrorFormat("[PROFILE]: Unable to connect to Profile " +
"Server {0}. Exception {1}", server, ex);
Hashtable ErrorHash = new Hashtable();
ErrorHash["success"] = false;
ErrorHash["errorMessage"] = "Unable to fetch profile data at this time. ";
ErrorHash["errorURI"] = "";
return ErrorHash;
}
catch (SocketException ex)
{
m_log.ErrorFormat(
"[PROFILE]: Unable to connect to Profile Server {0}. Method {1}, params {2}. " +
"Exception {3}", server, method, ReqParams, ex);
Hashtable ErrorHash = new Hashtable();
ErrorHash["success"] = false;
ErrorHash["errorMessage"] = "Unable to fetch profile data at this time. ";
ErrorHash["errorURI"] = "";
return ErrorHash;
}
catch (XmlException ex)
{
m_log.ErrorFormat(
"[PROFILE]: Unable to connect to Profile Server {0}. Method {1}, params {2}. " +
"Exception {3}", server, method, ReqParams.ToString(), ex);
Hashtable ErrorHash = new Hashtable();
ErrorHash["success"] = false;
ErrorHash["errorMessage"] = "Unable to fetch profile data at this time. ";
ErrorHash["errorURI"] = "";
return ErrorHash;
}
if (Resp.IsFault)
{
Hashtable ErrorHash = new Hashtable();
ErrorHash["success"] = false;
ErrorHash["errorMessage"] = "Unable to fetch profile data at this time. ";
ErrorHash["errorURI"] = "";
return ErrorHash;
}
Hashtable RespData = (Hashtable)Resp.Value;
return RespData;
}
}
}