WebServiceHandler.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. //
  2. // System.Web.Services.Protocols.WebServiceHandler.cs
  3. //
  4. // Author:
  5. // Tim Coleman ([email protected])
  6. // Lluis Sanchez Gual ([email protected])
  7. //
  8. // Copyright (C) Tim Coleman, 2002
  9. //
  10. //
  11. // Permission is hereby granted, free of charge, to any person obtaining
  12. // a copy of this software and associated documentation files (the
  13. // "Software"), to deal in the Software without restriction, including
  14. // without limitation the rights to use, copy, modify, merge, publish,
  15. // distribute, sublicense, and/or sell copies of the Software, and to
  16. // permit persons to whom the Software is furnished to do so, subject to
  17. // the following conditions:
  18. //
  19. // The above copyright notice and this permission notice shall be
  20. // included in all copies or substantial portions of the Software.
  21. //
  22. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  23. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  24. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  25. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  26. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  27. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  28. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  29. //
  30. using System;
  31. using System.Reflection;
  32. using System.Web;
  33. using System.Web.Services;
  34. using System.Web.SessionState;
  35. namespace System.Web.Services.Protocols
  36. {
  37. internal class WebServiceHandler: IHttpHandler
  38. {
  39. Type _type;
  40. HttpContext _context;
  41. HttpSessionState session;
  42. public WebServiceHandler (Type type)
  43. {
  44. _type = type;
  45. }
  46. public Type ServiceType
  47. {
  48. get { return _type; }
  49. }
  50. public virtual bool IsReusable
  51. {
  52. get { return false; }
  53. }
  54. protected HttpContext Context {
  55. set { _context = value; }
  56. }
  57. protected HttpSessionState Session {
  58. set { this.session = value; }
  59. }
  60. internal virtual MethodStubInfo GetRequestMethod (HttpContext context)
  61. {
  62. return null;
  63. }
  64. public virtual void ProcessRequest (HttpContext context)
  65. {
  66. }
  67. protected object CreateServerInstance ()
  68. {
  69. object ws = Activator.CreateInstance (ServiceType);
  70. WebService wsi = ws as WebService;
  71. if (wsi != null) {
  72. wsi.SetContext (_context);
  73. }
  74. return ws;
  75. }
  76. }
  77. }