UsingProxyClass.asmx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <%@ WebService Language="C#" Class="Samples.AspNet.UsingProxyClass" %>
  2. using System;
  3. using System.Web;
  4. using System.Web.Services;
  5. using System.Web.Services.Protocols;
  6. using System.Web.Script.Services;
  7. using System.Web.Script.Serialization;
  8. using System.Collections.Generic;
  9. namespace Samples.AspNet
  10. {
  11. // Define the color type to
  12. // exchange with the client.
  13. public class ColorObject
  14. {
  15. public string message;
  16. public string[] rgb;
  17. public ColorObject()
  18. {
  19. this.message = "The default color is Red";
  20. this.rgb = new string[] { "FF", "00", "00" };
  21. }
  22. }
  23. [WebService(Namespace = "http://tempuri.org/")]
  24. [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
  25. [ScriptService]
  26. public class UsingProxyClass :
  27. System.Web.Services.WebService
  28. {
  29. // Note, because the ColorObject is the returned type
  30. // it does not require that you apply
  31. // the attribute [GenerateScriptType(typeof(ColorObject))]
  32. // to the service class to allow client script
  33. // access.
  34. [WebMethod]
  35. public ColorObject GetDefaultColor()
  36. {
  37. // Instantiate the default color object.
  38. ColorObject co = new ColorObject();
  39. return co;
  40. }
  41. [WebMethod]
  42. public ColorObject SetColor(ColorObject color)
  43. {
  44. // Instantiate the color object.
  45. ColorObject co = new ColorObject();
  46. // Assign the passed values.
  47. co.message = color.message;
  48. co.rgb = color.rgb;
  49. return co;
  50. }
  51. }
  52. }