/// <summary> /// Executes requests from streams. /// </summary> /// <param name="config"></param> /// <param name="serverStream">the <see cref="IServerStream"/> to process</param> public void Execute(IXmlRpcStreamRequestConfig config, IServerStream serverStream) { Stream inputStream; XmlRpcResponse response = new XmlRpcResponse(); try { inputStream = GetInputStream(config, serverStream); IXmlRpcRequest request = GetRequest(config, inputStream); response.Result = Execute(request); } catch (XmlRpcException ex) { response.Fault = ex.Fault; } catch (Exception ex) { response.Fault = new XmlRpcFault(0, ex.Message, ex); } Stream outputStream = GetOutputStream(config, serverStream); WriteResponse(config, outputStream, response); }
public GridRegion GetHyperlinkRegion(GridRegion gatekeeper, UUID regionID, UUID agentID, string agentHomeURI, out string message) { Hashtable hash = new Hashtable(); hash["region_uuid"] = regionID.ToString(); if (agentID != UUID.Zero) { hash["agent_id"] = agentID.ToString(); if (agentHomeURI != null) { hash["agent_home_uri"] = agentHomeURI; } } IList paramList = new ArrayList(); paramList.Add(hash); ServicePointManagerTimeoutSupport.ResetHosts(); XmlRpcRequest request = new XmlRpcRequest("get_region", paramList); m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: contacting " + gatekeeper.ServerURI); XmlRpcResponse response = null; try { response = request.Send(gatekeeper.ServerURI, 10000); } catch (Exception e) { message = "Error contacting grid."; m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: Exception " + e.Message); return(null); } if (response.IsFault) { message = "Error contacting grid."; m_log.ErrorFormat("[GATEKEEPER SERVICE CONNECTOR]: remote call returned an error: {0}", response.FaultString); return(null); } hash = (Hashtable)response.Value; //foreach (Object o in hash) // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); try { bool success = false; Boolean.TryParse((string)hash["result"], out success); if (hash["message"] != null) { message = (string)hash["message"]; } else if (success) { message = null; } else { message = "The teleport destination could not be found."; // probably the dest grid is old and doesn't send 'message', but the most common problem is that the region is unavailable } if (success) { GridRegion region = new GridRegion(); UUID.TryParse((string)hash["uuid"], out region.RegionID); //m_log.Debug(">> HERE, uuid: " + region.RegionID); int n = 0; if (hash["x"] != null) { Int32.TryParse((string)hash["x"], out n); region.RegionLocX = n; //m_log.Debug(">> HERE, x: " + region.RegionLocX); } if (hash["y"] != null) { Int32.TryParse((string)hash["y"], out n); region.RegionLocY = n; //m_log.Debug(">> HERE, y: " + region.RegionLocY); } if (hash["size_x"] != null) { Int32.TryParse((string)hash["size_x"], out n); region.RegionSizeX = n; //m_log.Debug(">> HERE, x: " + region.RegionLocX); } if (hash["size_y"] != null) { Int32.TryParse((string)hash["size_y"], out n); region.RegionSizeY = n; //m_log.Debug(">> HERE, y: " + region.RegionLocY); } if (hash["region_name"] != null) { region.RegionName = (string)hash["region_name"]; //m_log.Debug(">> HERE, region_name: " + region.RegionName); } if (hash["hostname"] != null) { region.ExternalHostName = (string)hash["hostname"]; //m_log.Debug(">> HERE, hostname: " + region.ExternalHostName); } if (hash["http_port"] != null) { uint p = 0; UInt32.TryParse((string)hash["http_port"], out p); region.HttpPort = p; //m_log.Debug(">> HERE, http_port: " + region.HttpPort); } if (hash["internal_port"] != null) { int p = 0; Int32.TryParse((string)hash["internal_port"], out p); region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p); //m_log.Debug(">> HERE, internal_port: " + region.InternalEndPoint); } if (hash["server_uri"] != null) { region.ServerURI = (string)hash["server_uri"]; //m_log.Debug(">> HERE, server_uri: " + region.ServerURI); } // Successful return return(region); } } catch (Exception e) { message = "Error parsing response from grid."; m_log.Error("[GATEKEEPER SERVICE CONNECTOR]: Got exception while parsing hyperlink response " + e.StackTrace); return(null); } return(null); }
public XmlRpcResponse XmlRpcRemoteData(XmlRpcRequest request, IPEndPoint remoteClient) { XmlRpcResponse response = new XmlRpcResponse(); Hashtable requestData = (Hashtable)request.Params[0]; bool GoodXML = (requestData.Contains("Channel") && requestData.Contains("IntValue") && requestData.Contains("StringValue")); if (GoodXML) { UUID channel = new UUID((string)requestData["Channel"]); RPCChannelInfo rpcChanInfo; if (m_openChannels.TryGetValue(channel, out rpcChanInfo)) { string intVal = Convert.ToInt32(requestData["IntValue"]).ToString(); string strVal = (string)requestData["StringValue"]; RPCRequestInfo rpcInfo; lock (XMLRPCListLock) { rpcInfo = new RPCRequestInfo(rpcChanInfo.GetPrimID(), rpcChanInfo.GetItemID(), channel, strVal, intVal); m_rpcPending.Add(rpcInfo.GetMessageID(), rpcInfo); } int timeoutCtr = 0; while (!rpcInfo.IsProcessed() && (timeoutCtr < RemoteReplyScriptTimeout)) { Thread.Sleep(RemoteReplyScriptWait); timeoutCtr += RemoteReplyScriptWait; } if (rpcInfo.IsProcessed()) { Hashtable param = new Hashtable(); param["StringValue"] = rpcInfo.GetStrRetval(); param["IntValue"] = rpcInfo.GetIntRetval(); ArrayList parameters = new ArrayList { param }; response.Value = parameters; rpcInfo = null; } else { response.SetFault(-1, "Script timeout"); rpcInfo = null; } } else { response.SetFault(-1, "Invalid channel"); } } //Make sure that the cmd handler thread is running m_scriptModule.PokeThreads(UUID.Zero); return(response); }
public XmlRpcResponse XmlRpcMapBlockMethod(XmlRpcRequest request, IPEndPoint remoteClient) { int xmin = 980, ymin = 980, xmax = 1020, ymax = 1020; Hashtable requestData = (Hashtable)request.Params[0]; if (requestData.ContainsKey("xmin")) { xmin = (Int32)requestData["xmin"]; } if (requestData.ContainsKey("ymin")) { ymin = (Int32)requestData["ymin"]; } if (requestData.ContainsKey("xmax")) { xmax = (Int32)requestData["xmax"]; } if (requestData.ContainsKey("ymax")) { ymax = (Int32)requestData["ymax"]; } //CFK: The second log is more meaningful and either standard or fast generally occurs. //CFK: m_log.Info("[MAP]: World map request for range (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")"); XmlRpcResponse response = new XmlRpcResponse(); Hashtable responseData = new Hashtable(); response.Value = responseData; IList simProfileList = new ArrayList(); bool fastMode = (m_config.DatabaseProvider == "OpenSim.Data.MySQL.dll" || m_config.DatabaseProvider == "OpenSim.Data.MSSQL.dll"); if (fastMode) { List <RegionProfileData> neighbours = m_gridDBService.GetRegions((uint)xmin, (uint)ymin, (uint)xmax, (uint)ymax); foreach (RegionProfileData aSim in neighbours) { Hashtable simProfileBlock = new Hashtable(); simProfileBlock["x"] = aSim.regionLocX.ToString(); simProfileBlock["y"] = aSim.regionLocY.ToString(); //m_log.DebugFormat("[MAP]: Sending neighbour info for {0},{1}", aSim.regionLocX, aSim.regionLocY); simProfileBlock["name"] = aSim.regionName; simProfileBlock["access"] = aSim.AccessLevel.ToString(); simProfileBlock["region-flags"] = 512; simProfileBlock["water-height"] = 0; simProfileBlock["agents"] = 1; simProfileBlock["map-image-id"] = aSim.regionMapTextureID.ToString(); // For Sugilite compatibility simProfileBlock["regionhandle"] = aSim.regionHandle.ToString(); simProfileBlock["sim_ip"] = aSim.serverIP; simProfileBlock["sim_port"] = aSim.serverPort.ToString(); simProfileBlock["sim_uri"] = aSim.serverURI.ToString(); simProfileBlock["uuid"] = aSim.UUID.ToString(); simProfileBlock["remoting_port"] = aSim.remotingPort.ToString(); simProfileBlock["http_port"] = aSim.httpPort.ToString(); simProfileList.Add(simProfileBlock); } m_log.Info("[MAP]: Fast map " + simProfileList.Count.ToString() + " regions @ (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")"); } else { RegionProfileData simProfile; for (int x = xmin; x < xmax + 1; x++) { for (int y = ymin; y < ymax + 1; y++) { ulong regHandle = Utils.UIntsToLong((uint)(x * Constants.RegionSize), (uint)(y * Constants.RegionSize)); simProfile = m_gridDBService.GetRegion(regHandle); if (simProfile != null) { Hashtable simProfileBlock = new Hashtable(); simProfileBlock["x"] = x; simProfileBlock["y"] = y; simProfileBlock["name"] = simProfile.regionName; simProfileBlock["access"] = simProfile.AccessLevel.ToString(); simProfileBlock["region-flags"] = 0; simProfileBlock["water-height"] = 20; simProfileBlock["agents"] = 1; simProfileBlock["map-image-id"] = simProfile.regionMapTextureID.ToString(); // For Sugilite compatibility simProfileBlock["regionhandle"] = simProfile.regionHandle.ToString(); simProfileBlock["sim_ip"] = simProfile.serverIP.ToString(); simProfileBlock["sim_port"] = simProfile.serverPort.ToString(); simProfileBlock["sim_uri"] = simProfile.serverURI.ToString(); simProfileBlock["uuid"] = simProfile.UUID.ToString(); simProfileBlock["remoting_port"] = simProfile.remotingPort.ToString(); simProfileBlock["http_port"] = simProfile.httpPort; simProfileList.Add(simProfileBlock); } } } m_log.Info("[MAP]: Std map " + simProfileList.Count.ToString() + " regions @ (" + xmin + "," + ymin + ")..(" + xmax + "," + ymax + ")"); } responseData["sim-profiles"] = simProfileList; return(response); }
/// <summary> /// Performed when a region connects to the grid server initially. /// </summary> /// <param name="request">The XML RPC Request</param> /// <returns>Startup parameters</returns> public XmlRpcResponse XmlRpcSimulatorLoginMethod(XmlRpcRequest request, IPEndPoint remoteClient) { RegionProfileData sim; RegionProfileData existingSim; Hashtable requestData = (Hashtable)request.Params[0]; UUID uuid; if (!requestData.ContainsKey("UUID") || !UUID.TryParse((string)requestData["UUID"], out uuid)) { m_log.Debug("[LOGIN PRELUDE]: Region connected without a UUID, sending back error response."); return(ErrorResponse("No UUID passed to grid server - unable to connect you")); } try { sim = RegionFromRequest(requestData); } catch (FormatException e) { m_log.Debug("[LOGIN PRELUDE]: Invalid login parameters, sending back error response."); return(ErrorResponse("Wrong format in login parameters. Please verify parameters." + e.ToString())); } m_log.InfoFormat("[LOGIN BEGIN]: Received login request from simulator: {0}", sim.regionName); if (!m_config.AllowRegionRegistration) { m_log.DebugFormat( "[LOGIN END]: Disabled region registration blocked login request from simulator: {0}", sim.regionName); return(ErrorResponse("This grid is currently not accepting region registrations.")); } int majorInterfaceVersion = 0; if (requestData.ContainsKey("major_interface_version")) { int.TryParse((string)requestData["major_interface_version"], out majorInterfaceVersion); } if (majorInterfaceVersion != VersionInfo.MajorInterfaceVersion) { return(ErrorResponse( String.Format( "Your region service implements OGS1 interface version {0}" + " but this grid requires that the region implement OGS1 interface version {1} to connect." + " Try changing to OpenSimulator {2}", majorInterfaceVersion, VersionInfo.MajorInterfaceVersion, m_opensimVersion))); } existingSim = m_gridDBService.GetRegion(sim.regionHandle); if (existingSim == null || existingSim.UUID == sim.UUID || sim.UUID != sim.originUUID) { try { if (existingSim == null) { ValidateNewRegionKeys(sim); } else { ValidateOverwriteKeys(sim, existingSim); } ValidateRegionContactable(sim); } catch (LoginException e) { string logMsg = e.Message; if (e.InnerException != null) { logMsg += ", " + e.InnerException.Message; } m_log.WarnFormat("[LOGIN END]: {0}", logMsg); return(e.XmlRpcErrorResponse); } DataResponse insertResponse = m_gridDBService.AddUpdateRegion(sim, existingSim); switch (insertResponse) { case DataResponse.RESPONSE_OK: m_log.Info("[LOGIN END]: " + (existingSim == null ? "New" : "Existing") + " sim login successful: " + sim.regionName); break; case DataResponse.RESPONSE_ERROR: m_log.Warn("[LOGIN END]: Sim login failed (Error): " + sim.regionName); break; case DataResponse.RESPONSE_INVALIDCREDENTIALS: m_log.Warn("[LOGIN END]: " + "Sim login failed (Invalid Credentials): " + sim.regionName); break; case DataResponse.RESPONSE_AUTHREQUIRED: m_log.Warn("[LOGIN END]: " + "Sim login failed (Authentication Required): " + sim.regionName); break; } XmlRpcResponse response = CreateLoginResponse(sim); return(response); } else { m_log.Warn("[LOGIN END]: Failed to login region " + sim.regionName + " at location " + sim.regionLocX + " " + sim.regionLocY + " currently occupied by " + existingSim.regionName); return(ErrorResponse("Another region already exists at that location. Please try another.")); } }
public bool LinkRegion(GridRegion info, out UUID regionID, out ulong realHandle, out string externalName, out string imageURL, out string reason) { regionID = UUID.Zero; imageURL = string.Empty; realHandle = 0; externalName = string.Empty; reason = string.Empty; Hashtable hash = new Hashtable(); hash["region_name"] = info.RegionName; IList paramList = new ArrayList(); paramList.Add(hash); XmlRpcRequest request = new XmlRpcRequest("link_region", paramList); m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: Linking to " + info.ServerURI); XmlRpcResponse response = null; try { response = request.Send(info.ServerURI, 10000); } catch (Exception e) { m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: Exception " + e.Message); reason = "Error contacting remote server"; return(false); } if (response.IsFault) { reason = response.FaultString; m_log.ErrorFormat("[GATEKEEPER SERVICE CONNECTOR]: remote call returned an error: {0}", response.FaultString); return(false); } hash = (Hashtable)response.Value; //foreach (Object o in hash) // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); try { bool success = false; Boolean.TryParse((string)hash["result"], out success); if (success) { UUID.TryParse((string)hash["uuid"], out regionID); //m_log.Debug(">> HERE, uuid: " + regionID); if ((string)hash["handle"] != null) { realHandle = Convert.ToUInt64((string)hash["handle"]); //m_log.Debug(">> HERE, realHandle: " + realHandle); } if (hash["region_image"] != null) { imageURL = (string)hash["region_image"]; //m_log.Debug(">> HERE, imageURL: " + imageURL); } if (hash["external_name"] != null) { externalName = (string)hash["external_name"]; //m_log.Debug(">> HERE, externalName: " + externalName); } } } catch (Exception e) { reason = "Error parsing return arguments"; m_log.Error("[GATEKEEPER SERVICE CONNECTOR]: Got exception while parsing hyperlink response " + e.StackTrace); return(false); } return(true); }
public XmlRpcResponse PreflightBuyLandPrepFunc(XmlRpcRequest request, IPEndPoint ep) { Hashtable requestData = (Hashtable)request.Params [0]; XmlRpcResponse ret = new XmlRpcResponse(); Hashtable retparam = new Hashtable(); Hashtable membershiplevels = new Hashtable(); membershiplevels.Add("levels", membershiplevels); Hashtable landuse = new Hashtable(); Hashtable level = new Hashtable { { "id", "00000000-0000-0000-0000-000000000000" }, { m_connector.GetConfig().UpgradeMembershipUri, "Premium Membership" } }; if (requestData.ContainsKey("agentId") && requestData.ContainsKey("currencyBuy")) { UUID agentId; UUID.TryParse((string)requestData ["agentId"], out agentId); UserCurrency currency = m_connector.GetUserCurrency(agentId); IUserProfileInfo profile = Framework.Utilities.DataManager.RequestPlugin <IProfileConnector> ("IProfileConnector").GetUserProfile(agentId); OSDMap replyData = null; bool response = false; UserInfo user = m_agentInfoService.GetUserInfo(agentId.ToString()); if (user == null) { landuse.Add("action", false); retparam.Add("success", false); retparam.Add("currency", currency); retparam.Add("membership", level); retparam.Add("landuse", landuse); retparam.Add("confirm", "asdfajsdkfjasdkfjalsdfjasdf"); ret.Value = retparam; } else { OSDMap map = new OSDMap(); map ["Method"] = "GetLandData"; map ["AgentID"] = agentId; m_syncMessagePoster.Get(user.CurrentRegionURI, map, (o) => { replyData = o; response = true; }); while (!response) { Thread.Sleep(10); } if (replyData == null || replyData ["Success"] == false) { landuse.Add("action", false); retparam.Add("success", false); retparam.Add("currency", currency); retparam.Add("membership", level); retparam.Add("landuse", landuse); retparam.Add("confirm", "asdfajsdkfjasdkfjalsdfjasdf"); ret.Value = retparam; } else { if (replyData.ContainsKey("SalePrice")) { int landTierNeeded = (int)(currency.LandInUse + replyData ["Area"].AsInteger()); bool needsUpgrade = false; switch (profile.MembershipGroup) { case "Premium": case "": needsUpgrade = landTierNeeded >= currency.Tier; break; case "Banned": needsUpgrade = true; break; } landuse.Add("action", needsUpgrade); retparam.Add("success", true); retparam.Add("currency", currency); retparam.Add("membership", level); retparam.Add("landuse", landuse); retparam.Add("confirm", "asdfajsdkfjasdkfjalsdfjasdf"); ret.Value = retparam; } } } } return(ret); }
public static void TestCreateRecord() { XmlRpcClient client = new XmlRpcClient(); client.Url = Url; client.Path = "common"; // LOGIN XmlRpcRequest requestLogin = new XmlRpcRequest("authenticate"); requestLogin.AddParams(db, user, pass, XmlRpcParameter.EmptyStruct()); XmlRpcResponse responseLogin = client.Execute(requestLogin); Console.WriteLine("authenticate"); Console.WriteLine("REQUEST: "); client.WriteRequest(Console.Out); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("RESPONSE: "); client.WriteResponse(Console.Out); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("LOGIN: "******"object"; XmlRpcRequest requestCreate = new XmlRpcRequest("execute_kw"); requestCreate.AddParams(db, responseLogin.GetInt(), pass, "res.partner", "create", XmlRpcParameter.AsArray( XmlRpcParameter.AsStruct( XmlRpcParameter.AsMember("name", "Albert Einstein") , XmlRpcParameter.AsMember("image", Convert.ToBase64String(File.ReadAllBytes("img/einstein.jpg"))) , XmlRpcParameter.AsMember("email", "*****@*****.**") ) ) ); XmlRpcResponse responseCreate = client.Execute(requestCreate); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("create"); Console.WriteLine("REQUEST: "); client.WriteRequest(Console.Out); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("RESPONSE: "); client.WriteResponse(Console.Out); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("READ: "); if (responseCreate.IsFault()) { Console.WriteLine(responseCreate.GetFaultString()); } else { Console.WriteLine(responseCreate.GetString()); } }
/// <summary> /// metaWeblog.getPost /// </summary> /// <param name="response"></param> /// <returns></returns> private XElement BuildGetPost(XmlRpcResponse response) { return(BuildPost(response.Post)); }
/// <summary> /// metaWeblog.editPost, blogger.deletePost /// </summary> /// <param name="response"></param> /// <returns></returns> private XElement BuildBool(XmlRpcResponse response) { return(new XElement("boolean", response.Completed ? "1" : "0")); }
public override byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) { XmlRpcRequest xmlRpcRequest = null; XmlRpcResponse xmlRpcResponse = null; string requestBody = null; byte[] response; Encoding encoding = Encoding.UTF8; StreamReader streamReader = new StreamReader(request, encoding); requestBody = streamReader.ReadToEnd(); streamReader.Close(); try { xmlRpcRequest = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody); } catch (XmlException e) { m_log.ErrorFormat("[XMLRPC STREAM HANDLER]: XmlRpc request failed to deserialize: {0} -> {1}", e, requestBody); xmlRpcRequest = null; } if (xmlRpcRequest != null) { string methodName = xmlRpcRequest.MethodName; if (methodName != null) { xmlRpcRequest.Params.Add(httpRequest.RemoteIPEndPoint); // Param[1] xmlRpcRequest.Params.Add(httpRequest.Url); // Param[2] xmlRpcRequest.Params.Add(getForwardedFor(httpRequest)); // Param[3] try { xmlRpcResponse = m_xmlrpcMethod(xmlRpcRequest, httpRequest.RemoteIPEndPoint); } catch (Exception e) { string errorMessage = String.Format( "Requested method [{0}] from {1} threw exception: {2} {3}", methodName, httpRequest.RemoteIPEndPoint.Address, e.Message, e.StackTrace); m_log.ErrorFormat("[XMLRPC STREAM HANDLER]: {0}", errorMessage); // if the registered XmlRpc method threw an exception, we pass a fault-code along xmlRpcResponse = new XmlRpcResponse(); // Code probably set in accordance with http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php xmlRpcResponse.SetFault(-32603, errorMessage); } } else { xmlRpcResponse = new XmlRpcResponse(); // Code set in accordance with http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php xmlRpcResponse.SetFault( XmlRpcErrorCodes.SERVER_ERROR_METHOD, String.Format("Requested method [{0}] not found", methodName)); } response = Encoding.UTF8.GetBytes(XmlRpcResponseSerializer.Singleton.Serialize(xmlRpcResponse)); httpResponse.ContentType = "text/xml"; } else { response = Encoding.UTF8.GetBytes("Not found"); httpResponse.ContentType = "text/plain"; httpResponse.StatusCode = 404; httpResponse.StatusDescription = "Not Found"; httpResponse.ProtocolVersion = new System.Version("1.0"); m_log.ErrorFormat( "[XMLRPC STREAM HANDLER]: Handler not found for http request {0} {1}", httpRequest.HttpMethod, httpRequest.Url.PathAndQuery); } httpResponse.ContentLength64 = response.LongLength; httpResponse.ContentEncoding = Encoding.UTF8; httpResponse.SendChunked = false; return(response); }
public static XmlRpcResponse XmlRpcAdminMethod(XmlRpcRequest request, IPEndPoint remoteClient) { m_log.Debug("[IRC-Bridge]: XML RPC Admin Entry"); XmlRpcResponse response = new XmlRpcResponse(); Hashtable responseData = new Hashtable(); try { Hashtable requestData = (Hashtable)request.Params[0]; bool found = false; string region = String.Empty; if (m_password != String.Empty) { if (!requestData.ContainsKey("password")) { throw new Exception("Invalid request"); } if ((string)requestData["password"] != m_password) { throw new Exception("Invalid request"); } } if (!requestData.ContainsKey("region")) { throw new Exception("No region name specified"); } region = (string)requestData["region"]; foreach (RegionState rs in m_regions) { if (rs.Region == region) { responseData["server"] = rs.cs.Server; responseData["port"] = (int)rs.cs.Port; responseData["user"] = rs.cs.User; responseData["channel"] = rs.cs.IrcChannel; responseData["enabled"] = rs.cs.irc.Enabled; responseData["connected"] = rs.cs.irc.Connected; responseData["nickname"] = rs.cs.irc.Nick; found = true; break; } } if (!found) { throw new Exception(String.Format("Region <{0}> not found", region)); } responseData["success"] = true; } catch (Exception e) { m_log.ErrorFormat("[IRC-Bridge] XML RPC Admin request failed : {0}", e.Message); responseData["success"] = "false"; responseData["error"] = e.Message; } finally { response.Value = responseData; } m_log.Debug("[IRC-Bridge]: XML RPC Admin Exit"); return(response); }
public XmlRpcResponse HandleXMLRPCLogin(XmlRpcRequest request, IPEndPoint remoteClient) { Hashtable requestData = (Hashtable)request.Params[0]; if (m_Proxy && request.Params[3] != null) { IPEndPoint ep = NetworkUtils.GetClientIPFromXFF((string)request.Params[3]); if (ep != null) { remoteClient = ep; } } if (requestData != null) { if (((requestData.ContainsKey("first") && requestData["first"] != null && requestData.ContainsKey("last") && requestData["last"] != null) || requestData.ContainsKey("username") && requestData["username"] != null) && ((requestData.ContainsKey("passwd") && requestData["passwd"] != null) || (requestData.ContainsKey("web_login_key") && requestData["web_login_key"] != null))) { string first = requestData.ContainsKey("first") ? requestData["first"].ToString() : ""; string last = requestData.ContainsKey("last") ? requestData["last"].ToString() : ""; string name = requestData.ContainsKey("username") ? requestData["username"].ToString() : ""; string passwd = ""; if (!requestData.ContainsKey("web_login_key")) { passwd = requestData["passwd"].ToString(); } else { passwd = requestData["web_login_key"].ToString(); } string startLocation = string.Empty; if (requestData.ContainsKey("start")) { startLocation = requestData["start"].ToString(); } string clientVersion = "Unknown"; if (requestData.Contains("version") && requestData["version"] != null) { clientVersion = requestData["version"].ToString(); } //MAC BANNING START string mac = (string)requestData["mac"]; if (mac == "") { return(FailedXMLRPCResponse("Bad Viewer Connection.")); } string channel = "Unknown"; if (requestData.Contains("channel") && requestData["channel"] != null) { channel = requestData["channel"].ToString(); } if (channel == "") { return(FailedXMLRPCResponse("Bad Viewer Connection.")); } string id0 = "Unknown"; if (requestData.Contains("id0") && requestData["id0"] != null) { id0 = requestData["id0"].ToString(); } LoginResponse reply = null; string loginName = (name == "" || name == null) ? first + " " + last : name; reply = m_loginService.Login(UUID.Zero, loginName, "UserAccount", passwd, startLocation, clientVersion, channel, mac, id0, remoteClient, requestData); XmlRpcResponse response = new XmlRpcResponse { Value = reply.ToHashtable() }; return(response); } } return(FailedXMLRPCResponse()); }
public static void TestReadRecords() { XmlRpcClient client = new XmlRpcClient(); client.Url = Url; client.Path = "common"; // LOGIN XmlRpcRequest requestLogin = new XmlRpcRequest("authenticate"); requestLogin.AddParams(db, user, pass, XmlRpcParameter.EmptyStruct()); XmlRpcResponse responseLogin = client.Execute(requestLogin); // Console.WriteLine("authenticate"); // Console.WriteLine("REQUEST: "); // client.WriteRequest(Console.Out); // Console.WriteLine(); // Console.WriteLine(); // Console.WriteLine("RESPONSE: "); // client.WriteResponse(Console.Out); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("LOGIN: "******"object"; XmlRpcRequest requestSearch = new XmlRpcRequest("execute_kw"); requestSearch.AddParams(db, responseLogin.GetInt(), pass, "res.partner", "search", XmlRpcParameter.AsArray( XmlRpcParameter.AsArray( XmlRpcParameter.AsArray("is_company", "=", true), XmlRpcParameter.AsArray("customer", "=", true) ) ) ); requestSearch.AddParamStruct( XmlRpcParameter.AsMember("limit", 2) ); XmlRpcResponse responseSearch = client.Execute(requestSearch); // Console.WriteLine(); // Console.WriteLine(); // Console.WriteLine("search"); // Console.WriteLine("REQUEST: "); // client.WriteRequest(Console.Out); // Console.WriteLine(); // Console.WriteLine(); // Console.WriteLine("RESPONSE: "); // client.WriteResponse(Console.Out); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("SEARCH: "); if (responseSearch.IsFault()) { Console.WriteLine(responseSearch.GetFaultString()); } else { Console.WriteLine(responseSearch.GetString()); } // READ XmlRpcRequest requestRead = new XmlRpcRequest("execute_kw"); requestRead.AddParams(db, responseLogin.GetInt(), pass, "res.partner", "read", XmlRpcParameter.AsArray( responseSearch.GetArray() ) ); requestRead.AddParamStruct(XmlRpcParameter.AsMember("fields", XmlRpcParameter.AsArray("name") ) ); XmlRpcResponse responseRead = client.Execute(requestRead); // Console.WriteLine(); // Console.WriteLine(); // Console.WriteLine("read"); // Console.WriteLine("REQUEST: "); // client.WriteRequest(Console.Out); // Console.WriteLine(); // Console.WriteLine(); // Console.WriteLine("RESPONSE: "); // client.WriteResponse(Console.Out); Console.WriteLine(); Console.WriteLine(); Console.WriteLine("READ: "); if (responseRead.IsFault()) { Console.WriteLine(responseRead.GetFaultString()); } else { Console.WriteLine(responseRead.GetString()); } }
private static IXmlRpcResponse ReadParamReponse(XmlReader reader, IXmlRpcStreamConfig config, ITypeSerializerFactory typeSerializerFactory) { IList list = RecursiveTypeSerializer.ReadParams(reader, config, typeSerializerFactory); XmlRpcResponse response = new XmlRpcResponse(list.Count > 0 ? list[0] : null); return response; }
/// <summary> /// metaWeblog.newPost /// </summary> /// <param name="response"></param> /// <returns>string postid</returns> /// <remarks> /// https://codex.wordpress.org/XML-RPC_MetaWeblog_API#metaWeblog.newPost /// </remarks> private XElement BuildNewPost(XmlRpcResponse response) { return(new XElement("string", response.PostId)); }
private void SerializeResponse(IMessage responseMsg, ref ITransportHeaders responseHeaders, ref Stream responseStream, IXmlRpcStreamRequestConfig config) { XmlRpcResponseSerializer serializer = new XmlRpcResponseSerializer(); responseStream = new MemoryStream(); responseHeaders = new TransportHeaders(); ReturnMessage retMsg = (ReturnMessage)responseMsg; XmlRpcResponse response; if (retMsg.Exception == null) { response = new XmlRpcResponse(retMsg.ReturnValue); } else if (retMsg.Exception is XmlRpcException) { response = new XmlRpcResponse(); response.Fault = (retMsg.Exception as XmlRpcException).Fault; } else { response = new XmlRpcResponse(); response.Fault = new XmlRpcFault(1, retMsg.Exception.Message); } serializer.WriteResponse(responseStream, response, config, TypeSerializerFactory); responseHeaders["Content-Type"] = "text/xml; charset=\"utf-8\""; }
/// <summary> /// wp.newCategory /// </summary> /// <param name="response"></param> /// <returns>int category_id</returns> /// <remarks> /// https://codex.wordpress.org/XML-RPC_wp#wp.newCategory /// </remarks> private XElement BuildNewCategory(XmlRpcResponse response) { return(new XElement("int", response.CategoryId)); }
public XmlRpcResponse XmlRpcResponseXmlRPCUpdateUserProfile(XmlRpcRequest request, IPEndPoint remoteClient) { // Check IP Endpoint Access if (!TrustManager.Instance.IsTrustedPeer(remoteClient)) { return(Util.CreateTrustManagerAccessDeniedResponse()); } m_log.Debug("[UserManager]: Got request to update user profile."); XmlRpcResponse response = new XmlRpcResponse(); Hashtable requestData = (Hashtable)request.Params[0]; Hashtable responseData = new Hashtable(); if (!requestData.Contains("avatar_uuid")) { return(Util.CreateUnknownUserErrorResponse()); } UUID UserUUID = new UUID((string)requestData["avatar_uuid"]); UserProfileData userProfile = m_userDataBaseService.GetUserProfile(UserUUID); if (null == userProfile) { return(Util.CreateUnknownUserErrorResponse()); } // don't know how yet. if (requestData.Contains("AllowPublish")) { } if (requestData.Contains("FLImageID")) { userProfile.FirstLifeImage = new UUID((string)requestData["FLImageID"]); } if (requestData.Contains("ImageID")) { userProfile.Image = new UUID((string)requestData["ImageID"]); } // dont' know how yet if (requestData.Contains("MaturePublish")) { } if (requestData.Contains("AboutText")) { userProfile.AboutText = (string)requestData["AboutText"]; } if (requestData.Contains("FLAboutText")) { userProfile.FirstLifeAboutText = (string)requestData["FLAboutText"]; } if (requestData.Contains("profileURL")) { userProfile.ProfileURL = (string)requestData["profileURL"]; } if (requestData.Contains("home_region")) { try { userProfile.HomeRegion = Convert.ToUInt64((string)requestData["home_region"]); } catch (ArgumentException) { m_log.Error("[PROFILE]:Failed to set home region, Invalid Argument"); } catch (FormatException) { m_log.Error("[PROFILE]:Failed to set home region, Invalid Format"); } catch (OverflowException) { m_log.Error("[PROFILE]:Failed to set home region, Value was too large"); } } if (requestData.Contains("home_region_id")) { UUID regionID; UUID.TryParse((string)requestData["home_region_id"], out regionID); userProfile.HomeRegionID = regionID; } if (requestData.Contains("home_pos_x")) { try { userProfile.HomeLocationX = (float)Convert.ToDouble((string)requestData["home_pos_x"]); } catch (InvalidCastException) { m_log.Error("[PROFILE]:Failed to set home postion x"); } } if (requestData.Contains("home_pos_y")) { try { userProfile.HomeLocationY = (float)Convert.ToDouble((string)requestData["home_pos_y"]); } catch (InvalidCastException) { m_log.Error("[PROFILE]:Failed to set home postion y"); } } if (requestData.Contains("home_pos_z")) { try { userProfile.HomeLocationZ = (float)Convert.ToDouble((string)requestData["home_pos_z"]); } catch (InvalidCastException) { m_log.Error("[PROFILE]:Failed to set home postion z"); } } if (requestData.Contains("home_look_x")) { try { userProfile.HomeLookAtX = (float)Convert.ToDouble((string)requestData["home_look_x"]); } catch (InvalidCastException) { m_log.Error("[PROFILE]:Failed to set home lookat x"); } } if (requestData.Contains("home_look_y")) { try { userProfile.HomeLookAtY = (float)Convert.ToDouble((string)requestData["home_look_y"]); } catch (InvalidCastException) { m_log.Error("[PROFILE]:Failed to set home lookat y"); } } if (requestData.Contains("home_look_z")) { try { userProfile.HomeLookAtZ = (float)Convert.ToDouble((string)requestData["home_look_z"]); } catch (InvalidCastException) { m_log.Error("[PROFILE]:Failed to set home lookat z"); } } if (requestData.Contains("user_flags")) { try { userProfile.UserFlags = Convert.ToInt32((string)requestData["user_flags"]); } catch (InvalidCastException) { m_log.Error("[PROFILE]:Failed to set user flags"); } } if (requestData.Contains("god_level")) { try { userProfile.GodLevel = Convert.ToInt32((string)requestData["god_level"]); } catch (InvalidCastException) { m_log.Error("[PROFILE]:Failed to set god level"); } } if (requestData.Contains("custom_type")) { try { userProfile.CustomType = (string)requestData["custom_type"]; } catch (InvalidCastException) { m_log.Error("[PROFILE]:Failed to set custom type"); } } if (requestData.Contains("partner")) { try { userProfile.Partner = new UUID((string)requestData["partner"]); } catch (InvalidCastException) { m_log.Error("[PROFILE]:Failed to set partner"); } } else { userProfile.Partner = UUID.Zero; } // call plugin! bool ret = m_userDataBaseService.UpdateUserProfile(userProfile); responseData["returnString"] = ret.ToString(); response.Value = responseData; return(response); }
/// <summary> /// Try all the registered xmlrpc handlers when an xmlrpc request is received. /// Sends back an XMLRPC unknown request response if no handler is registered for the requested method. /// </summary> /// <param name="request"></param> /// <param name="response"></param> byte [] HandleXmlRpcRequests(OSHttpRequest request, OSHttpResponse response) { string requestBody = HttpServerHandlerHelpers.ReadString(request.InputStream); requestBody = requestBody.Replace("<base64></base64>", ""); string responseString = string.Empty; XmlRpcRequest xmlRprcRequest = null; try { xmlRprcRequest = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(requestBody); } catch (XmlException e) { MainConsole.Instance.WarnFormat( "[Base HTTP server]: Got XMLRPC request with invalid XML from {0}. XML was '{1}'. Sending blank response. Exception: {2}", request.RemoteIPEndPoint, requestBody, e.ToString()); } if (xmlRprcRequest != null) { string methodName = xmlRprcRequest.MethodName; if (methodName != null) { xmlRprcRequest.Params.Add(request.RemoteIPEndPoint); // Param[1] XmlRpcResponse xmlRpcResponse; XmlRpcMethod method; bool methodWasFound; lock (m_rpcHandlers) methodWasFound = m_rpcHandlers.TryGetValue(methodName, out method); if (methodWasFound) { xmlRprcRequest.Params.Add(request.Url); // Param[2] string xff = "X-Forwarded-For"; string xfflower = xff.ToLower(); foreach (string s in request.Headers.AllKeys) { if (s != null && s.Equals(xfflower)) { xff = xfflower; break; } } xmlRprcRequest.Params.Add(request.Headers.Get(xff)); // Param[3] try { xmlRpcResponse = method(xmlRprcRequest, request.RemoteIPEndPoint); } catch (Exception e) { string errorMessage = string.Format( "Requested method [{0}] from {1} threw exception: {2} {3}", methodName, request.RemoteIPEndPoint.Address, e.Message, e.StackTrace); MainConsole.Instance.ErrorFormat("[Base HTTP server]: {0}", errorMessage); // if the registered XmlRpc method threw an exception, we pass a fault-code along xmlRpcResponse = new XmlRpcResponse(); // Code probably set in accordance with http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php xmlRpcResponse.SetFault(-32603, errorMessage); } } else { xmlRpcResponse = new XmlRpcResponse(); // Code set in accordance with http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php xmlRpcResponse.SetFault( XmlRpcErrorCodes.SERVER_ERROR_METHOD, string.Format("Requested method [{0}] not found", methodName)); } response.ContentType = "text/xml"; responseString = XmlRpcResponseSerializer.Singleton.Serialize(xmlRpcResponse); } else { //HandleLLSDRequests(request, response); response.ContentType = "text/plain"; response.StatusCode = 404; response.StatusDescription = "Not Found"; responseString = "Not found"; MainConsole.Instance.ErrorFormat( "[Base HTTP server]: Handler not found for http request {0} {1}", request.HttpMethod, request.Url.PathAndQuery); } } byte [] buffer = Encoding.UTF8.GetBytes(responseString); response.SendChunked = false; response.ContentEncoding = Encoding.UTF8; return(buffer); }
public GridRegion GetHyperlinkRegion(GridRegion gatekeeper, UUID regionID) { Hashtable hash = new Hashtable(); hash["region_uuid"] = regionID.ToString(); IList paramList = new ArrayList(); paramList.Add(hash); XmlRpcRequest request = new XmlRpcRequest("get_region", paramList); m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: contacting " + gatekeeper.ServerURI); XmlRpcResponse response = null; try { response = request.Send(gatekeeper.ServerURI, 10000); } catch (Exception e) { m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: Exception " + e.Message); return(null); } if (response.IsFault) { m_log.ErrorFormat("[GATEKEEPER SERVICE CONNECTOR]: remote call returned an error: {0}", response.FaultString); return(null); } hash = (Hashtable)response.Value; //foreach (Object o in hash) // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); try { bool success = false; Boolean.TryParse((string)hash["result"], out success); if (success) { GridRegion region = new GridRegion(); UUID.TryParse((string)hash["uuid"], out region.RegionID); //m_log.Debug(">> HERE, uuid: " + region.RegionID); int n = 0; if (hash["x"] != null) { Int32.TryParse((string)hash["x"], out n); region.RegionLocX = n; //m_log.Debug(">> HERE, x: " + region.RegionLocX); } if (hash["y"] != null) { Int32.TryParse((string)hash["y"], out n); region.RegionLocY = n; //m_log.Debug(">> HERE, y: " + region.RegionLocY); } if (hash["region_name"] != null) { region.RegionName = (string)hash["region_name"]; //m_log.Debug(">> HERE, region_name: " + region.RegionName); } if (hash["hostname"] != null) { region.ExternalHostName = (string)hash["hostname"]; //m_log.Debug(">> HERE, hostname: " + region.ExternalHostName); } if (hash["http_port"] != null) { uint p = 0; UInt32.TryParse((string)hash["http_port"], out p); region.HttpPort = p; //m_log.Debug(">> HERE, http_port: " + region.HttpPort); } if (hash["internal_port"] != null) { int p = 0; Int32.TryParse((string)hash["internal_port"], out p); region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p); //m_log.Debug(">> HERE, internal_port: " + region.InternalEndPoint); } if (hash["server_uri"] != null) { region.ServerURI = (string)hash["server_uri"]; //m_log.Debug(">> HERE, server_uri: " + region.ServerURI); } // Successful return return(region); } } catch (Exception e) { m_log.Error("[GATEKEEPER SERVICE CONNECTOR]: Got exception while parsing hyperlink response " + e.StackTrace); return(null); } return(null); }
/// <summary> /// Encapsulate the XmlRpc call to standardize security and error handling. /// </summary> private Hashtable XmlRpcCall(UUID requestingAgentID, string function, Hashtable param) { XmlRpcResponse resp = null; string CacheKey = null; // Only bother with the cache if it isn't disabled. if (m_cacheTimeout > 0) { if (!function.StartsWith("groups.get")) { // Any and all updates cause the cache to clear m_memoryCache.Clear(); } else { StringBuilder sb = new StringBuilder(requestingAgentID + function); foreach (object key in param.Keys) { if (param[key] != null) { sb.AppendFormat(",{0}:{1}", key.ToString(), param[key].ToString()); } } CacheKey = sb.ToString(); m_memoryCache.TryGetValue(CacheKey, out resp); } } if (resp == null) { if (m_debugEnabled) { m_log.DebugFormat("[XMLRPC-GROUPS-CONNECTOR]: Cache miss for key {0}", CacheKey); } string UserService; UUID SessionID; GetClientGroupRequestID(requestingAgentID, out UserService, out SessionID); param.Add("RequestingAgentID", requestingAgentID.ToString()); param.Add("RequestingAgentUserService", UserService); param.Add("RequestingSessionID", SessionID.ToString()); param.Add("ReadKey", m_groupReadKey); param.Add("WriteKey", m_groupWriteKey); IList parameters = new ArrayList(); parameters.Add(param); ConfigurableKeepAliveXmlRpcRequest req; req = new ConfigurableKeepAliveXmlRpcRequest(function, parameters, m_disableKeepAlive); try { resp = req.Send(m_groupsServerURI); } catch (Exception e) { m_log.ErrorFormat( "[XMLRPC-GROUPS-CONNECTOR]: An error has occured while attempting to access the XmlRpcGroups server method {0} at {1}: {2}", function, m_groupsServerURI, e.Message); if (m_debugEnabled) { m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0}", e.StackTrace); foreach (string ResponseLine in req.RequestResponse.Split(new string[] { Environment.NewLine }, StringSplitOptions.None)) { m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} ", ResponseLine); } foreach (string key in param.Keys) { m_log.WarnFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} :: {1}", key, param[key].ToString()); } } if ((m_cacheTimeout > 0) && (CacheKey != null)) { m_memoryCache.AddOrUpdate(CacheKey, resp, 10.0); } Hashtable respData = new Hashtable(); respData.Add("error", e.ToString()); return(respData); } if ((m_cacheTimeout > 0) && (CacheKey != null)) { m_memoryCache.AddOrUpdate(CacheKey, resp, 10.0); } } if (resp.Value is Hashtable) { Hashtable respData = (Hashtable)resp.Value; if (respData.Contains("error") && !respData.Contains("succeed")) { LogRespDataToConsoleError(requestingAgentID, function, param, respData); } return(respData); } m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: The XmlRpc server returned a {1} instead of a hashtable for {0}", function, resp.Value.GetType().ToString()); if (resp.Value is ArrayList) { ArrayList al = (ArrayList)resp.Value; m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: Contains {0} elements", al.Count); foreach (object o in al) { m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} :: {1}", o.GetType().ToString(), o.ToString()); } } else { m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: Function returned: {0}", resp.Value.ToString()); } Hashtable error = new Hashtable(); error.Add("error", "invalid return value"); return(error); }
public XmlRpcResponse XmlRpcUpdateWelcomeMethod(XmlRpcRequest request, IPEndPoint remoteClient) { m_log.Info("[Concierge]: processing UpdateWelcome request"); XmlRpcResponse response = new XmlRpcResponse(); Hashtable responseData = new Hashtable(); try { Hashtable requestData = (Hashtable)request.Params[0]; checkStringParameters(request, new string[] { "password", "region", "welcome" }); // check password if (!String.IsNullOrEmpty(m_xmlRpcPassword) && (string)requestData["password"] != m_xmlRpcPassword) { throw new Exception("wrong password"); } if (String.IsNullOrEmpty(m_welcomes)) { throw new Exception("welcome templates are not enabled, ask your OpenSim operator to set the \"welcomes\" option in the [Concierge] section of OpenSim.ini"); } string msg = (string)requestData["welcome"]; if (String.IsNullOrEmpty(msg)) { throw new Exception("empty parameter \"welcome\""); } string regionName = (string)requestData["region"]; IScene scene = m_scenes.Find(delegate(IScene s) { return(s.RegionInfo.RegionName == regionName); }); if (scene == null) { throw new Exception(String.Format("unknown region \"{0}\"", regionName)); } if (!m_conciergedScenes.Contains(scene)) { throw new Exception(String.Format("region \"{0}\" is not a concierged region.", regionName)); } string welcome = Path.Combine(m_welcomes, regionName); if (File.Exists(welcome)) { m_log.InfoFormat("[Concierge]: UpdateWelcome: updating existing template \"{0}\"", welcome); string welcomeBackup = String.Format("{0}~", welcome); if (File.Exists(welcomeBackup)) { File.Delete(welcomeBackup); } File.Move(welcome, welcomeBackup); } File.WriteAllText(welcome, msg); responseData["success"] = "true"; response.Value = responseData; } catch (Exception e) { m_log.InfoFormat("[Concierge]: UpdateWelcome failed: {0}", e.Message); responseData["success"] = "false"; responseData["error"] = e.Message; response.Value = responseData; } m_log.Debug("[Concierge]: done processing UpdateWelcome request"); return(response); }
/// <summary>Submit two XML-RPC calls to Google. One to suggest spelling on a phrase and /// the next to do a basic search.</summary> public static void Main() { // Use the console logger above. Logger.Delegate = new Logger.LoggerDelegate(WriteEntry); // Send the sample.Ping RPC using the Send method which gives you a little more control... XmlRpcRequest client = new XmlRpcRequest(); client.MethodName = SPELL_CHECK; client.Params.Add(PHRASE); client.Params.Add(KEY); Console.WriteLine("Looking up: " + PHRASE); try { Console.WriteLine("Request: " + client); XmlRpcResponse response = client.Send(URL, 10000); Console.WriteLine("Response: " + response); if (response.IsFault) { Console.WriteLine("Fault {0}: {1}", response.FaultCode, response.FaultString); } else { Console.WriteLine("Returned: " + response.Value); } } catch (XmlRpcException serverException) { Console.WriteLine("Fault {0}: {1}", serverException.FaultCode, serverException.FaultString); } catch (Exception e) { Console.WriteLine("Exception " + e); } client.MethodName = RESULTS; client.Params.Clear(); client.Params.Add("C# XML-RPC .Net"); client.Params.Add(0); client.Params.Add(5); client.Params.Add(""); client.Params.Add(""); client.Params.Add(false); client.Params.Add(""); client.Params.Add(""); client.Params.Add(KEY); try { Hashtable results = (Hashtable)client.Invoke(URL); foreach (Hashtable result in ((Hashtable)results["resultElements"]).Values) { Console.WriteLine("Title: {0}", result["title"]); Console.WriteLine("URL: {0}", result["URL"]); Console.WriteLine("Context: {0}", result["snippet"]); Console.WriteLine("------------------------------------------------------------"); } } catch (XmlRpcException serverException) { Console.WriteLine("Fault {0}: {1}", serverException.FaultCode, serverException.FaultString); } catch (Exception e) { Console.WriteLine("Exception " + e); } }
/// <summary> /// Returns an XML RPC response to a simulator profile request /// </summary> /// <param name="request"></param> /// <returns></returns> public XmlRpcResponse XmlRpcSimulatorDataRequestMethod(XmlRpcRequest request, IPEndPoint remoteClient) { Hashtable requestData = (Hashtable)request.Params[0]; Hashtable responseData = new Hashtable(); RegionProfileData simData = null; if (requestData.ContainsKey("region_UUID")) { UUID regionID = new UUID((string)requestData["region_UUID"]); simData = m_gridDBService.GetRegion(regionID); if (simData == null) { m_log.WarnFormat("[DATA] didn't find region for regionID {0} from {1}", regionID, request.Params.Count > 1 ? request.Params[1] : "unknwon source"); } } else if (requestData.ContainsKey("region_handle")) { //CFK: The if/else below this makes this message redundant. //CFK: m_log.Info("requesting data for region " + (string) requestData["region_handle"]); ulong regionHandle = Convert.ToUInt64((string)requestData["region_handle"]); simData = m_gridDBService.GetRegion(regionHandle); if (simData == null) { m_log.WarnFormat("[DATA] didn't find region for regionHandle {0} from {1}", regionHandle, request.Params.Count > 1 ? request.Params[1] : "unknwon source"); } } else if (requestData.ContainsKey("region_name_search")) { string regionName = (string)requestData["region_name_search"]; simData = m_gridDBService.GetRegion(regionName); if (simData == null) { m_log.WarnFormat("[DATA] didn't find region for regionName {0} from {1}", regionName, request.Params.Count > 1 ? request.Params[1] : "unknwon source"); } } else { m_log.Warn("[DATA] regionlookup without regionID, regionHandle or regionHame"); } if (simData == null) { //Sim does not exist responseData["error"] = "Sim does not exist"; } else { m_log.Info("[DATA]: found " + (string)simData.regionName + " regionHandle = " + (string)requestData["region_handle"]); responseData["sim_ip"] = simData.serverIP; responseData["sim_port"] = simData.serverPort.ToString(); responseData["server_uri"] = simData.serverURI; responseData["http_port"] = simData.httpPort.ToString(); responseData["remoting_port"] = simData.remotingPort.ToString(); responseData["region_locx"] = simData.regionLocX.ToString(); responseData["region_locy"] = simData.regionLocY.ToString(); responseData["region_UUID"] = simData.UUID.Guid.ToString(); responseData["region_name"] = simData.regionName; responseData["regionHandle"] = simData.regionHandle.ToString(); } XmlRpcResponse response = new XmlRpcResponse(); response.Value = responseData; return(response); }
public XmlRpcResponse HandleXMLRPCLogin(XmlRpcRequest request, IPEndPoint remoteClient) { Hashtable requestData = (Hashtable)request.Params[0]; if (request.Params[3] != null) { IPEndPoint ep = Util.GetClientIPFromXFF((string)request.Params[3]); if (ep != null) { // Bang! remoteClient = ep; } } if (requestData != null) { // Debug code to show exactly what login parameters the viewer is sending us. // TODO: Extract into a method that can be generally applied if one doesn't already exist. // foreach (string key in requestData.Keys) // { // object value = requestData[key]; // Console.WriteLine("{0}:{1}", key, value); // if (value is ArrayList) // { // ICollection col = value as ICollection; // foreach (object item in col) // Console.WriteLine(" {0}", item); // } // } if (((requestData.ContainsKey("first") && requestData["first"] != null && requestData.ContainsKey("last") && requestData["last"] != null) || (requestData.ContainsKey("username") && requestData["username"] != null)) && ( (requestData.ContainsKey("passwd") && requestData["passwd"] != null) || (!requestData.ContainsKey("passwd") && requestData.ContainsKey("web_login_key") && requestData["web_login_key"] != null && requestData["web_login_key"].ToString() != UUID.Zero.ToString()) )) { string first = null; string last = null; if (requestData.ContainsKey("username")) { first = requestData["username"].ToString(); last = "Resident"; } else { first = requestData["first"].ToString(); last = requestData["last"].ToString(); } string passwd = null; if (requestData.ContainsKey("passwd")) { passwd = requestData["passwd"].ToString(); } else if (requestData.ContainsKey("web_login_key")) { passwd = "$1$" + requestData["web_login_key"].ToString(); m_log.InfoFormat("[LOGIN]: XMLRPC Login Req key {0}", passwd); } string startLocation = string.Empty; UUID scopeID = UUID.Zero; if (requestData["scope_id"] != null) { scopeID = new UUID(requestData["scope_id"].ToString()); } if (requestData.ContainsKey("start")) { startLocation = requestData["start"].ToString(); } string clientVersion = "Unknown"; if (requestData.Contains("version") && requestData["version"] != null) { clientVersion = requestData["version"].ToString(); } // We should do something interesting with the client version... string channel = "Unknown"; if (requestData.Contains("channel") && requestData["channel"] != null) { channel = requestData["channel"].ToString(); } string mac = "Unknown"; if (requestData.Contains("mac") && requestData["mac"] != null) { mac = requestData["mac"].ToString(); } string id0 = "Unknown"; if (requestData.Contains("id0") && requestData["id0"] != null) { id0 = requestData["id0"].ToString(); } //m_log.InfoFormat("[LOGIN]: XMLRPC Login Requested for {0} {1}, starting in {2}, using {3}", first, last, startLocation, clientVersion); LoginResponse reply = null; reply = m_LocalService.Login(first, last, passwd, startLocation, scopeID, clientVersion, channel, mac, id0, remoteClient); XmlRpcResponse response = new XmlRpcResponse(); response.Value = reply.ToHashtable(); return(response); } } return(FailedXMLRPCResponse()); }
public LoginException(string message, string xmlRpcMessage, Exception e) : base(message, e) { // FIXME: Might be neater to refactor and put the method inside here m_xmlRpcErrorResponse = GridXmlRpcModule.ErrorResponse(xmlRpcMessage); }
/// <summary> /// Takes an XmlRpcResponse object from a call to a Boolean method in the Confluence API and /// returns true if the method returned true. /// </summary> /// <param name="response"></param> /// <returns></returns> internal bool OperationSuccessful(XmlRpcResponse response) { return(!response.IsFault && response.Value != null && (Boolean)response.Value); }
/* * TODO: More work on the response codes. Right now * returning 200 for success or 499 for exception */ public void SendRequest() { Culture.SetCurrentCulture(); Hashtable param = new Hashtable(); // Check if channel is an UUID // if not, use as method name UUID parseUID; string mName = "llRemoteData"; if (!string.IsNullOrEmpty(Channel)) { if (!UUID.TryParse(Channel, out parseUID)) { mName = Channel; } else { param["Channel"] = Channel; } } param["StringValue"] = Sdata; param["IntValue"] = Convert.ToString(Idata); ArrayList parameters = new ArrayList { param }; XmlRpcRequest req = new XmlRpcRequest(mName, parameters); try { XmlRpcResponse resp = req.Send(DestURL, 30000); if (resp != null) { Hashtable respParms; if (resp.Value.GetType().Equals(typeof(Hashtable))) { respParms = (Hashtable)resp.Value; } else { ArrayList respData = (ArrayList)resp.Value; respParms = (Hashtable)respData[0]; } if (respParms != null) { if (respParms.Contains("StringValue")) { Sdata = (string)respParms["StringValue"]; } if (respParms.Contains("IntValue")) { Idata = Convert.ToInt32(respParms["IntValue"]); } if (respParms.Contains("faultString")) { Sdata = (string)respParms["faultString"]; } if (respParms.Contains("faultCode")) { Idata = Convert.ToInt32(respParms["faultCode"]); } } } } catch (Exception we) { Sdata = we.Message; MainConsole.Instance.Warn("[SendRemoteDataRequest]: Request failed"); MainConsole.Instance.Warn(we.StackTrace); } _finished = true; }
public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt) { position = Vector3.UnitY; lookAt = Vector3.UnitY; Hashtable hash = new Hashtable(); hash["userID"] = userID.ToString(); IList paramList = new ArrayList(); paramList.Add(hash); XmlRpcRequest request = new XmlRpcRequest("get_home_region", paramList); XmlRpcResponse response = null; try { response = request.Send(m_ServerURL, 10000); } catch (Exception) { return(null); } if (response.IsFault) { return(null); } hash = (Hashtable)response.Value; //foreach (Object o in hash) // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); try { bool success = false; Boolean.TryParse((string)hash["result"], out success); if (success) { GridRegion region = new GridRegion(); UUID.TryParse((string)hash["uuid"], out region.RegionID); //m_log.Debug(">> HERE, uuid: " + region.RegionID); int n = 0; if (hash["x"] != null) { Int32.TryParse((string)hash["x"], out n); region.RegionLocX = n; //m_log.Debug(">> HERE, x: " + region.RegionLocX); } if (hash["y"] != null) { Int32.TryParse((string)hash["y"], out n); region.RegionLocY = n; //m_log.Debug(">> HERE, y: " + region.RegionLocY); } if (hash["region_name"] != null) { region.RegionName = (string)hash["region_name"]; //m_log.Debug(">> HERE, name: " + region.RegionName); } if (hash["hostname"] != null) { region.ExternalHostName = (string)hash["hostname"]; } if (hash["http_port"] != null) { uint p = 0; UInt32.TryParse((string)hash["http_port"], out p); region.HttpPort = p; } if (hash["internal_port"] != null) { int p = 0; Int32.TryParse((string)hash["internal_port"], out p); region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p); } if (hash["position"] != null) { Vector3.TryParse((string)hash["position"], out position); } if (hash["lookAt"] != null) { Vector3.TryParse((string)hash["lookAt"], out lookAt); } // Successful return return(region); } } catch (Exception) { return(null); } return(null); }
public XmlRpcResult(XmlRpcResponse response) { Response = response; }
/// <summary> /// Process a XMLRPC Grid Instant Message /// </summary> /// <param name="request">XMLRPC parameters /// </param> /// <returns>Nothing much</returns> protected virtual XmlRpcResponse processXMLRPCGridInstantMessage(XmlRpcRequest request, IPEndPoint remoteClient) { bool successful = false; // For now, as IMs seem to be a bit unreliable on OSGrid, catch all exception that // happen here and aren't caught and log them. try { // various rational defaults UUID fromAgentID = UUID.Zero; UUID toAgentID = UUID.Zero; UUID imSessionID = UUID.Zero; uint timestamp = 0; string fromAgentName = ""; string message = ""; byte dialog = (byte)0; bool fromGroup = false; byte offline = (byte)0; uint ParentEstateID = 0; Vector3 Position = Vector3.Zero; UUID RegionID = UUID.Zero; byte[] binaryBucket = new byte[0]; float pos_x = 0; float pos_y = 0; float pos_z = 0; //m_log.Info("Processing IM"); Hashtable requestData = (Hashtable)request.Params[0]; // Check if it's got all the data if (requestData.ContainsKey("from_agent_id") && requestData.ContainsKey("to_agent_id") && requestData.ContainsKey("im_session_id") && requestData.ContainsKey("timestamp") && requestData.ContainsKey("from_agent_name") && requestData.ContainsKey("message") && requestData.ContainsKey("dialog") && requestData.ContainsKey("from_group") && requestData.ContainsKey("offline") && requestData.ContainsKey("parent_estate_id") && requestData.ContainsKey("position_x") && requestData.ContainsKey("position_y") && requestData.ContainsKey("position_z") && requestData.ContainsKey("region_id") && requestData.ContainsKey("binary_bucket")) { // Do the easy way of validating the UUIDs UUID.TryParse((string)requestData["from_agent_id"], out fromAgentID); UUID.TryParse((string)requestData["to_agent_id"], out toAgentID); UUID.TryParse((string)requestData["im_session_id"], out imSessionID); UUID.TryParse((string)requestData["region_id"], out RegionID); try { timestamp = (uint)Convert.ToInt32((string)requestData["timestamp"]); } catch (ArgumentException) { } catch (FormatException) { } catch (OverflowException) { } fromAgentName = (string)requestData["from_agent_name"]; message = (string)requestData["message"]; if (message == null) { message = string.Empty; } // Bytes don't transfer well over XMLRPC, so, we Base64 Encode them. string requestData1 = (string)requestData["dialog"]; if (string.IsNullOrEmpty(requestData1)) { dialog = 0; } else { byte[] dialogdata = Convert.FromBase64String(requestData1); dialog = dialogdata[0]; } if ((string)requestData["from_group"] == "TRUE") { fromGroup = true; } string requestData2 = (string)requestData["offline"]; if (String.IsNullOrEmpty(requestData2)) { offline = 0; } else { byte[] offlinedata = Convert.FromBase64String(requestData2); offline = offlinedata[0]; } try { ParentEstateID = (uint)Convert.ToInt32((string)requestData["parent_estate_id"]); } catch (ArgumentException) { } catch (FormatException) { } catch (OverflowException) { } try { pos_x = float.Parse((string)requestData["position_x"]); } catch (ArgumentException) { } catch (FormatException) { } catch (OverflowException) { } try { pos_y = float.Parse((string)requestData["position_y"]); } catch (ArgumentException) { } catch (FormatException) { } catch (OverflowException) { } try { pos_z = float.Parse((string)requestData["position_z"]); } catch (ArgumentException) { } catch (FormatException) { } catch (OverflowException) { } Position = new Vector3(pos_x, pos_y, pos_z); string requestData3 = (string)requestData["binary_bucket"]; if (string.IsNullOrEmpty(requestData3)) { binaryBucket = new byte[0]; } else { binaryBucket = Convert.FromBase64String(requestData3); } // Create a New GridInstantMessageObject the the data GridInstantMessage gim = new GridInstantMessage(); gim.fromAgentID = fromAgentID.Guid; gim.fromAgentName = fromAgentName; gim.fromGroup = fromGroup; gim.imSessionID = imSessionID.Guid; gim.RegionID = UUID.Zero.Guid; // RegionID.Guid; gim.timestamp = timestamp; gim.toAgentID = toAgentID.Guid; gim.message = message; gim.dialog = dialog; gim.offline = offline; gim.ParentEstateID = ParentEstateID; gim.Position = Position; gim.binaryBucket = binaryBucket; //We don't allow god tps from other regions if (gim.dialog == (byte)InstantMessageDialog.GodLikeRequestTeleport) { gim.dialog = (byte)InstantMessageDialog.RequestTeleport; } // Trigger the Instant message in the scene. foreach (Scene scene in m_Scenes) { IScenePresence user; if (scene.TryGetScenePresence(toAgentID, out user)) { if (!user.IsChildAgent) { scene.EventManager.TriggerIncomingInstantMessage(gim); successful = true; } } } if (!successful) { // If the message can't be delivered to an agent, it // is likely to be a group IM. On a group IM, the // imSessionID = toAgentID = group id. Raise the // unhandled IM event to give the groups module // a chance to pick it up. We raise that in a random // scene, since the groups module is shared. // m_Scenes[0].EventManager.TriggerUnhandledInstantMessage(gim); } } } catch (Exception e) { m_log.Error("[INSTANT MESSAGE]: Caught unexpected exception:", e); successful = false; } //Send response back to region calling if it was successful // calling region uses this to know when to look up a user's location again. XmlRpcResponse resp = new XmlRpcResponse(); Hashtable respdata = new Hashtable(); if (successful) { respdata["success"] = "TRUE"; } else { respdata["success"] = "FALSE"; } resp.Value = respdata; return(resp); }
private static IXmlRpcResponse ReadFaultResponse(XmlReader reader, IXmlRpcStreamConfig config, ITypeSerializerFactory typeSerializerFactory) { IDictionary dict = null; do { reader.Read(); if (reader.NodeType == XmlNodeType.Element) { dict = (IDictionary)RecursiveTypeSerializer.ReadValue(reader, config, typeSerializerFactory); } } while (reader.NodeType != XmlNodeType.EndElement || !XmlRpcSpec.FAULT_TAG.Equals(reader.LocalName)); if (dict != null) { if (!dict.Contains(XmlRpcSpec.FAULT_CODE_TAG)) throw new XmlRpcException("Invalid XML-RPC response: missing fault code"); if (!dict.Contains(XmlRpcSpec.FAULT_STRING_TAG)) throw new XmlRpcException("Invalid XML-RPC response: missing fault string"); try { XmlRpcFault fault = new XmlRpcFault((Int32)dict[XmlRpcSpec.FAULT_CODE_TAG], (String)dict[XmlRpcSpec.FAULT_STRING_TAG]); XmlRpcResponse response = new XmlRpcResponse(null); response.Fault = fault; return response; } catch (Exception ex) { throw new XmlRpcException("Invalid XML-RPC response: " + ex.Message); } } throw new XmlRpcException("Invalid XML-RPC response."); }
/// <summary> /// Received from the user server when a user starts logging in. This call allows /// the region to prepare for direct communication from the client. Sends back an empty /// xmlrpc response on completion. /// </summary> /// <param name="request"></param> /// <returns></returns> public XmlRpcResponse ExpectUser(XmlRpcRequest request, IPEndPoint remoteClient) { XmlRpcResponse resp = new XmlRpcResponse(); //check the send key if (request.Params.Count < 2 || (string)request.Params[1] != _gridSendKey) { Hashtable respdata = new Hashtable(); respdata["success"] = "FALSE"; respdata["reason"] = "Grid authorization failed"; resp.Value = respdata; return(resp); } Hashtable requestData = (Hashtable)request.Params[0]; AgentCircuitData agentData = new AgentCircuitData(); agentData.SessionID = new UUID((string)requestData["session_id"]); agentData.SecureSessionID = new UUID((string)requestData["secure_session_id"]); agentData.FirstName = (string)requestData["firstname"]; agentData.LastName = (string)requestData["lastname"]; agentData.AgentID = new UUID((string)requestData["agent_id"]); agentData.CircuitCode = Convert.ToUInt32(requestData["circuit_code"]); agentData.CapsPath = (string)requestData["caps_path"]; ulong regionHandle = Convert.ToUInt64((string)requestData["regionhandle"]); if (requestData.ContainsKey("client_version")) { agentData.ClientVersion = (string)requestData["client_version"]; } else { m_log.Warn("[CLIENT]: ExpectUser missing client_version for " + agentData.AgentID.ToString()); } // Appearance if (requestData.ContainsKey("appearance")) { agentData.Appearance = new AvatarAppearance((Hashtable)requestData["appearance"]); } m_log.DebugFormat( "[CLIENT]: Incoming connection from {0} {1} {2}, circuit {3}: {4}", agentData.FirstName, agentData.LastName, agentData.AgentID, agentData.CircuitCode, agentData.ClientVersion); if (requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1")) { //m_log.Debug("[CLIENT]: Child agent detected"); agentData.child = true; } else { //m_log.Debug("[CLIENT]: Main agent detected"); agentData.startpos = new Vector3((float)Convert.ToDouble((string)requestData["startpos_x"]), (float)Convert.ToDouble((string)requestData["startpos_y"]), (float)Convert.ToDouble((string)requestData["startpos_z"])); agentData.child = false; } if (!RegionLoginsEnabled) { m_log.InfoFormat( "[CLIENT]: Denying access for user {0} {1} because region login is currently disabled", agentData.FirstName, agentData.LastName); Hashtable respdata = new Hashtable(); respdata["success"] = "FALSE"; respdata["reason"] = "region login currently disabled"; resp.Value = respdata; } else { bool success = false; string denyMess = String.Empty; Scene scene; if (TryGetRegion(regionHandle, out scene)) { if (scene.IsBlacklistedUser(agentData.AgentID)) { denyMess = "User is blacklisted from this region"; m_log.InfoFormat( "[CLIENT]: Denying access for user {0} {1} because user is blacklisted", agentData.FirstName, agentData.LastName); } else if (scene.RegionInfo.EstateSettings.IsBanned(agentData.AgentID)) { denyMess = "User is banned from this region"; m_log.InfoFormat( "[CLIENT]: Denying access for user {0} {1} because user is banned", agentData.FirstName, agentData.LastName); } else { string reason; if (scene.NewUserLogin(agentData, out reason)) { success = true; } else { denyMess = String.Format("Login refused by region: {0}", reason); m_log.InfoFormat( "[CLIENT]: Denying access for user {0} {1} because user connection was refused by the region", agentData.FirstName, agentData.LastName); } } } else { denyMess = "Region not found"; } if (success) { Hashtable respdata = new Hashtable(); respdata["success"] = "TRUE"; resp.Value = respdata; } else { Hashtable respdata = new Hashtable(); respdata["success"] = "FALSE"; respdata["reason"] = denyMess; resp.Value = respdata; } } return(resp); }
public ServerProcessing ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, out IMessage responseMsg, out ITransportHeaders responseHeaders, out Stream responseStream) { if (requestHeaders["SOAPAction"] != null) { // pass to next sink if this is a SOAP request with SOAPAction header. return NextChannelSink.ProcessMessage(sinkStack, requestMsg, requestHeaders, requestStream, out responseMsg, out responseHeaders, out responseStream); } XmlRpcHttpRequestConfig requestConfig = GetConfig(requestHeaders); try { MethodCall call = DeserializeRequest(requestHeaders, requestStream, requestConfig); sinkStack.Push(this, call); // forward to next sink in chain - pass request stream as null to // indicate that we have deserialized the request NextChannelSink.ProcessMessage(sinkStack, call, requestHeaders, null, out responseMsg, out responseHeaders, out responseStream); SerializeResponse(responseMsg, ref responseHeaders, ref responseStream, requestConfig); } catch (Exception ex) { responseMsg = new ReturnMessage(ex, (IMethodCallMessage)requestMsg); responseStream = new MemoryStream(); XmlRpcResponseSerializer serializer = new XmlRpcResponseSerializer(); XmlRpcResponse faultResponse = new XmlRpcResponse(); faultResponse.Fault = new XmlRpcFault(0, ex.Message); serializer.WriteResponse(responseStream, faultResponse, requestConfig, TypeSerializerFactory); responseHeaders = new TransportHeaders(); responseHeaders["Content-Type"] = "text/xml; charset=\"utf-8\""; } return ServerProcessing.Complete; }
public XmlRpcResponse certSend(String url, X509Certificate2 myClientCert, bool checkServerCert, Int32 timeout) { m_log.InfoFormat("[MONEY NSL RPC]: XmlRpcResponse certSend: connect to {0}", url); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); if (request == null) { throw new XmlRpcException(XmlRpcErrorCodes.TRANSPORT_ERROR, XmlRpcErrorCodes.TRANSPORT_ERROR_MSG + ": Could not create request with " + url); } request.Method = "POST"; request.ContentType = "text/xml"; request.AllowWriteStreamBuffering = true; request.Timeout = timeout; request.UserAgent = "NSLXmlRpcRequest"; if (myClientCert != null) { request.ClientCertificates.Add(myClientCert); // Own certificate m_log.ErrorFormat("[MONEY NSL RPC]: 111111111111111111111111111"); } if (!checkServerCert) { request.Headers.Add("NoVerifyCert", "true"); // Do not verify the certificate of the other party } Stream stream = null; try { stream = request.GetRequestStream(); } catch (Exception ex) { m_log.ErrorFormat("[MONEY NSL RPC]: GetRequestStream Error: {0}", ex); stream = null; } if (stream == null) { return(null); } // XmlTextWriter xml = new XmlTextWriter(stream, _encoding); _serializer.Serialize(xml, this); xml.Flush(); xml.Close(); HttpWebResponse response = null; try { response = (HttpWebResponse)request.GetResponse(); } catch (Exception ex) { m_log.ErrorFormat("[MONEY NSL RPC]: XmlRpcResponse certSend: GetResponse Error: {0}", ex.ToString()); } StreamReader input = new StreamReader(response.GetResponseStream()); string inputXml = input.ReadToEnd(); XmlRpcResponse resp = (XmlRpcResponse)_deserializer.Deserialize(inputXml); input.Close(); response.Close(); return(resp); }