public void writeCustomerMessage(CustomerMessage message) { RestClient client = new RestClient(SoftbladeParameters.getParameter(SoftbladeParameters.REST_SERVER)); // client.Authenticator = new HttpBasicAuthenticator(username, password); var request = new RestRequest(message.getUriPath() + "/put", Method.PUT); request.RequestFormat = DataFormat.Json; logger.Info("Writing message, raw: " + message); request.AddJsonBody(message); logger.Info("JSON: " + request); // execute the request IRestResponse response = client.Execute(request); if ((int)response.StatusCode < 200 || (int)response.StatusCode > 299) { logger.Error(response.StatusCode + ": Error writing REST message: " + response.ResponseStatus + response.StatusDescription + response.Content); throw new Exception("Error writing message"); } else { logger.Debug("Wrote message, response: " + response.Content); } logger.Debug("Exiting"); }
private static void writeMessage(string type, string message) { string source = SoftbladeParameters.getParameter(SoftbladeParameters.SOURCE); string customerId = SoftbladeParameters.getParameter(SoftbladeParameters.CUSTOMER_ID_PARAMETER); RestServer rs = new RestServer(); CustomerMessage output = new CustomerMessage(); output.setMessage(message); output.setCustomerId(customerId); output.setSource(source); output.setType(type); logger.Debug("Writing message: " + output.ToString()); if (sendToServer) { rs.writeCustomerMessage(output); } }
public void writeCustomerMessage(CustomerMessage message) { RestClient client = new RestClient(SoftbladeParameters.getParameter(SoftbladeParameters.REST_SERVER)); // client.Authenticator = new HttpBasicAuthenticator(username, password); var request = new RestRequest(message.getUriPath()+"/put", Method.PUT); request.RequestFormat = DataFormat.Json; logger.Info("Writing message, raw: " + message); request.AddJsonBody(message); logger.Info("JSON: " + request); // execute the request IRestResponse response = client.Execute(request); if ((int)response.StatusCode < 200 || (int)response.StatusCode > 299) { logger.Error(response.StatusCode + ": Error writing REST message: " + response.ResponseStatus + response.StatusDescription + response.Content); throw new Exception("Error writing message"); } else { logger.Debug("Wrote message, response: " + response.Content); } logger.Debug("Exiting"); }