33 using System.Xml.Serialization;
35 namespace OpenSim.Framework.Servers.HttpServer
42 public static void BeginPostObject<TRequest>(
string requestUrl, TRequest obj)
44 BeginPostObject(
"POST", requestUrl, obj);
47 public static void BeginPostObject<TRequest>(
string verb,
string requestUrl, TRequest obj)
49 Type type = typeof (TRequest);
51 WebRequest request = WebRequest.Create(requestUrl);
52 request.Method = verb;
53 request.ContentType =
"text/xml";
55 using (MemoryStream buffer =
new MemoryStream())
57 XmlWriterSettings settings =
new XmlWriterSettings();
58 settings.Encoding = Encoding.UTF8;
60 using (XmlWriter writer = XmlWriter.Create(buffer, settings))
62 XmlSerializer serializer =
new XmlSerializer(type);
63 serializer.Serialize(writer, obj);
67 int length = (int)buffer.Length;
68 request.ContentLength = length;
70 using (Stream requestStream = request.GetRequestStream())
71 requestStream.Write(buffer.ToArray(), 0, length);
75 request.BeginGetResponse(AsyncCallback, request);
78 private static void AsyncCallback(IAsyncResult result)
80 WebRequest request = (WebRequest) result.AsyncState;
81 using (WebResponse resp = request.EndGetResponse(result))
Makes an asynchronous REST request which doesn't require us to do anything with the response...