public void ProcessRequest(HttpContext ctx) { try { // // Verify the GET verb was used and that a query string is // specified. // if ("GET" != ctx.Request.RequestType.ToUpper()) { ctx.Response.AddHeader("Allow", "GET"); ctx.Response.StatusCode = 405; // Method Not Allowed return; } if (null == ctx.Request.QueryString["businessKey"]) { ctx.Response.StatusCode = 400; // Bad Request ctx.Response.Write("<h1>400 Bad Request</h1>Missing required argument 'businessKey'"); return; } // // Attempt to retrieve the business entity. // ConnectionManager.Open(false, false); string businessKey = ctx.Request.QueryString["businessKey"]; BusinessEntity be = new BusinessEntity(businessKey); be.Get(); // // Serialize the business Entity to the response stream // using UTF-8 encoding // // XmlSerializer serializer = new XmlSerializer( be.GetType() ); XmlSerializer serializer = XmlSerializerManager.GetSerializer(be.GetType()); UTF8Encoding utf8 = new UTF8Encoding(false); StreamWriter sr = new StreamWriter(ctx.Response.OutputStream, utf8); serializer.Serialize(sr, be); ctx.Response.AddHeader("Content-Type", "text/xml; charset=utf-8"); } catch (FormatException e) { // // We get a FormatException when passed a bad GUID. // ctx.Response.StatusCode = 400; // Bad Request ctx.Response.Write("<h1>400 Bad Request</h1>" + e.Message); } catch (SqlException e) { // // We get a SqlException when we could not get the data. // ctx.Response.StatusCode = 400; // Bad Request ctx.Response.Write("<h1>400 Bad Request</h1>" + e.Message); } catch (UDDIException e) { ctx.Response.StatusCode = 400; // Bad Request ctx.Response.Write("<h1>400 Bad Request</h1>" + e.Message); } catch (Exception e) { ctx.Response.StatusCode = 500; // Internal Server Error ctx.Response.Write("<h1>500 Internal Server Error</h1>"); Debug.OperatorMessage(SeverityType.Error, CategoryType.None, OperatorMessageType.None, e.ToString()); } finally { ConnectionManager.Close(); } }
public void Get() { BusinessEntity.Get(); }