WebMethodCommon.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. #region Copyright © 2015 CLIPSOFT Co.,Ltd. All Rights Reserved.
  2. //
  3. // All rights are reserved. Reproduction or transmission in whole or in part,
  4. // in any form or by any means, electronic, mechanical or otherwise, is
  5. // prohibited without the prior written consent of the copyright owner.
  6. //
  7. // Filename:PatientInfoCtrl.cs
  8. //
  9. #endregion
  10. using System;
  11. using System.Collections.Generic;
  12. using System.Linq;
  13. using System.Text;
  14. using System.ServiceModel;
  15. using System.ServiceModel.Description;
  16. namespace CLIP.eForm.Consent.UI
  17. {
  18. /// <summary>
  19. /// 웹서비스 연결 관련 클래스
  20. /// </summary>
  21. /// <remarks>
  22. /// <p>[설계자]</p>
  23. /// <p> 클립소프트 연구소 홍지철 (jchong@clipsoft.co.kr)</p>
  24. /// <p>[원본 작성자]</p>
  25. /// <p> 클립소프트 기술부 이창훈 (chlee@clipsoft.co.kr)</p>
  26. /// <p>[수정 작성자]</p>
  27. /// <p> 클립소프트 기술부 이인희</p>
  28. /// <p>----------------------------------------------------------------------------------------</p>
  29. /// <p>[HISTORY]</p>
  30. /// <p> 2015-07-30 : 최초작성</p>
  31. /// <p>----------------------------------------------------------------------------------------</p>
  32. /// </remarks>
  33. class WebMethodCommon
  34. {
  35. /// <summary>
  36. /// consentWebService를 리턴한다.
  37. /// </summary>
  38. /// <returns></returns>
  39. public static ConsentSvcRef.ConsentSvcSoapClient GetConsentWebService(string serverUrl)
  40. {
  41. ConsentSvcRef.ConsentSvcSoapClient consentWebService = null;
  42. var method = serverUrl.Substring(0, serverUrl.IndexOf(":"));
  43. BasicHttpBinding consentSvcBinding = null;
  44. if (method.ToUpper() == "HTTPS")
  45. {
  46. consentSvcBinding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
  47. System.Net.ServicePointManager.ServerCertificateValidationCallback += (s, cert, chain, sslPolicyErrors) => true;
  48. }
  49. else
  50. {
  51. consentSvcBinding = new BasicHttpBinding();
  52. }
  53. consentSvcBinding.Name = "ConsentSvcSoap";
  54. consentSvcBinding.MaxReceivedMessageSize = 2147483647;
  55. consentSvcBinding.MaxBufferSize = 2147483647;
  56. consentSvcBinding.MaxBufferPoolSize = 2147483647;
  57. consentSvcBinding.ReaderQuotas.MaxArrayLength = 2147483647;
  58. consentSvcBinding.ReaderQuotas.MaxBytesPerRead = 2147483647;
  59. consentSvcBinding.ReaderQuotas.MaxDepth = 2147483647;
  60. consentSvcBinding.ReaderQuotas.MaxNameTableCharCount = 2147483647;
  61. consentSvcBinding.ReaderQuotas.MaxStringContentLength = 2147483647;
  62. consentSvcBinding.BypassProxyOnLocal = false;
  63. consentSvcBinding.AllowCookies = false;
  64. EndpointAddress consentSvcendpoint = new EndpointAddress(serverUrl);
  65. consentWebService = new ConsentSvcRef.ConsentSvcSoapClient(consentSvcBinding, consentSvcendpoint);
  66. ConfigureClientEndPoint(consentWebService.Endpoint);
  67. return consentWebService;
  68. }
  69. /// <summary>
  70. /// hospitalWebService 리턴한다.
  71. /// </summary>
  72. /// <returns></returns>
  73. public static HospitalSvcRef.HospitalSvcSoapClient GetHospitalWebService(string serverUrl)
  74. {
  75. HospitalSvcRef.HospitalSvcSoapClient hospitalWebService = null;
  76. var method = serverUrl.Substring(0, serverUrl.IndexOf(":"));
  77. BasicHttpBinding hospitalSvcBinding = null;
  78. if (method.ToUpper() == "HTTPS")
  79. {
  80. hospitalSvcBinding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
  81. System.Net.ServicePointManager.ServerCertificateValidationCallback += (s, cert, chain, sslPolicyErrors) => true;
  82. }
  83. else
  84. {
  85. hospitalSvcBinding = new BasicHttpBinding();
  86. }
  87. //BasicHttpBinding hospitalSvcBinding = new BasicHttpBinding();
  88. hospitalSvcBinding.Name = "HospitalSvcSoap";
  89. hospitalSvcBinding.MaxReceivedMessageSize = 2147483647;
  90. hospitalSvcBinding.MaxBufferSize = 2147483647;
  91. hospitalSvcBinding.MaxBufferPoolSize = 2147483647;
  92. hospitalSvcBinding.ReaderQuotas.MaxArrayLength = 2147483647;
  93. hospitalSvcBinding.ReaderQuotas.MaxBytesPerRead = 2147483647;
  94. hospitalSvcBinding.ReaderQuotas.MaxDepth = 2147483647;
  95. hospitalSvcBinding.ReaderQuotas.MaxNameTableCharCount = 2147483647;
  96. hospitalSvcBinding.ReaderQuotas.MaxStringContentLength = 2147483647;
  97. hospitalSvcBinding.BypassProxyOnLocal = false;
  98. hospitalSvcBinding.AllowCookies = false;
  99. EndpointAddress hospitalSvcendpoint = new EndpointAddress(serverUrl);
  100. hospitalWebService = new HospitalSvcRef.HospitalSvcSoapClient(hospitalSvcBinding, hospitalSvcendpoint);
  101. ConfigureClientEndPoint(hospitalWebService.Endpoint);
  102. return hospitalWebService;
  103. }
  104. private static void ConfigureClientEndPoint(ServiceEndpoint endPoint)
  105. {
  106. //개체 그래프에서 직렬화 또는 역직렬화할 수 있는 최대 항목 수는 '65536'입니다. 개체 그래프를 변경하거나 MaxItemsInObjectGraph 할당량을 늘리십시오.
  107. foreach (OperationDescription operation in endPoint.Contract.Operations)
  108. {
  109. DataContractSerializerOperationBehavior dataContractBehavior = operation.Behaviors.Find<DataContractSerializerOperationBehavior>();
  110. if (dataContractBehavior != null)
  111. {
  112. dataContractBehavior.MaxItemsInObjectGraph = int.MaxValue;
  113. }
  114. }
  115. }
  116. }
  117. }