Exemplo n.º 1
0
        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();
            }
        }
Exemplo n.º 2
0
 public BusinessEntityExt(string businessKey)
 {
     BusinessEntity = new BusinessEntity(businessKey);
 }
Exemplo n.º 3
0
 public void Get()
 {
     BusinessEntity.Get();
 }
Exemplo n.º 4
0
 public void Remove(BusinessEntity value)
 {
     List.Remove(value);
 }
Exemplo n.º 5
0
 public bool Contains(BusinessEntity value)
 {
     return(List.Contains(value));
 }
Exemplo n.º 6
0
 public int IndexOf(BusinessEntity value)
 {
     return(List.IndexOf(value));
 }
Exemplo n.º 7
0
 public void Insert(int index, BusinessEntity value)
 {
     List.Insert(index, value);
 }
Exemplo n.º 8
0
 public int Add(BusinessEntity value)
 {
     return(List.Add(value));
 }