HttpPostProtocolImporter.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // System.Web.Services.Description.HttpPostProtocolImporter.cs
  3. //
  4. // Author:
  5. // Lluis Sanchez Gual ([email protected])
  6. //
  7. // Copyright (C) 2003 Ximian, Inc.
  8. //
  9. using System;
  10. using System.CodeDom;
  11. using System.Web.Services;
  12. using System.Web.Services.Protocols;
  13. using System.Xml.Serialization;
  14. using System.Xml;
  15. using System.Collections;
  16. using System.Configuration;
  17. namespace System.Web.Services.Description
  18. {
  19. internal class HttpPostProtocolImporter : HttpSimpleProtocolImporter
  20. {
  21. #region Constructors
  22. public HttpPostProtocolImporter ()
  23. {
  24. }
  25. #endregion // Constructors
  26. #region Properties
  27. public override string ProtocolName {
  28. get { return "HttpPost"; }
  29. }
  30. #endregion // Properties
  31. #region Methods
  32. protected override CodeTypeDeclaration BeginClass ()
  33. {
  34. CodeTypeDeclaration codeClass = base.BeginClass ();
  35. CodeTypeReference ctr = new CodeTypeReference ("System.Web.Services.Protocols.HttpPostClientProtocol");
  36. codeClass.BaseTypes.Add (ctr);
  37. return codeClass;
  38. }
  39. protected override Type GetInMimeFormatter ()
  40. {
  41. MimeContentBinding bin = OperationBinding.Input.Extensions.Find (typeof(MimeContentBinding)) as MimeContentBinding;
  42. if (bin == null) throw new Exception ("Http mime:content binding not found");
  43. if (bin.Type != "application/x-www-form-urlencoded") throw new Exception ("Encoding of mime:content binding not supported");
  44. return typeof (HtmlFormParameterWriter);
  45. }
  46. protected override bool IsBindingSupported ()
  47. {
  48. HttpBinding bin = (HttpBinding) Binding.Extensions.Find (typeof(HttpBinding));
  49. if (bin == null) return false;
  50. return bin.Verb == "POST";
  51. }
  52. #endregion
  53. }
  54. }