SoapProtocolImporter.cs 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  1. //
  2. // System.Web.Services.Description.SoapProtocolImporter.cs
  3. //
  4. // Author:
  5. // Tim Coleman ([email protected])
  6. // Lluis Sanchez Gual ([email protected])
  7. //
  8. // Copyright (C) Tim Coleman, 2002
  9. //
  10. using System.CodeDom;
  11. using System.Web.Services;
  12. using System.Web.Services.Protocols;
  13. using System.Web.Services.Configuration;
  14. using System.Xml;
  15. using System.Xml.Serialization;
  16. using System.Configuration;
  17. using System.Collections;
  18. namespace System.Web.Services.Description {
  19. public sealed class SoapProtocolImporter : ProtocolImporter {
  20. #region Fields
  21. SoapBinding soapBinding;
  22. SoapCodeExporter soapExporter;
  23. SoapSchemaImporter soapImporter;
  24. XmlCodeExporter xmlExporter;
  25. XmlSchemaImporter xmlImporter;
  26. CodeIdentifiers memberIds;
  27. ArrayList extensionImporters;
  28. Hashtable headerVariables;
  29. #endregion // Fields
  30. #region Constructors
  31. public SoapProtocolImporter ()
  32. {
  33. extensionImporters = ExtensionManager.BuildExtensionImporters ();
  34. }
  35. void SetBinding (SoapBinding soapBinding)
  36. {
  37. this.soapBinding = soapBinding;
  38. }
  39. #endregion // Constructors
  40. #region Properties
  41. public override string ProtocolName {
  42. get { return "Soap"; }
  43. }
  44. public SoapBinding SoapBinding {
  45. get { return soapBinding; }
  46. }
  47. public SoapCodeExporter SoapExporter {
  48. get { return soapExporter; }
  49. }
  50. public SoapSchemaImporter SoapImporter {
  51. get { return soapImporter; }
  52. }
  53. public XmlCodeExporter XmlExporter {
  54. get { return xmlExporter; }
  55. }
  56. public XmlSchemaImporter XmlImporter {
  57. get { return xmlImporter; }
  58. }
  59. #endregion // Properties
  60. #region Methods
  61. protected override CodeTypeDeclaration BeginClass ()
  62. {
  63. soapBinding = (SoapBinding) Binding.Extensions.Find (typeof(SoapBinding));
  64. CodeTypeDeclaration codeClass = new CodeTypeDeclaration (ClassName);
  65. string location = null;
  66. SoapAddressBinding sab = (SoapAddressBinding) Port.Extensions.Find (typeof(SoapAddressBinding));
  67. if (sab != null) location = sab.Location;
  68. string url = GetServiceUrl (location);
  69. CodeTypeReference ctr = new CodeTypeReference ("System.Web.Services.Protocols.SoapHttpClientProtocol");
  70. codeClass.BaseTypes.Add (ctr);
  71. CodeAttributeDeclaration att = new CodeAttributeDeclaration ("System.Web.Services.WebServiceBinding");
  72. att.Arguments.Add (GetArg ("Name", Port.Name));
  73. att.Arguments.Add (GetArg ("Namespace", Port.Binding.Namespace));
  74. AddCustomAttribute (codeClass, att, true);
  75. CodeConstructor cc = new CodeConstructor ();
  76. cc.Attributes = MemberAttributes.Public;
  77. CodeExpression ce = new CodeFieldReferenceExpression (new CodeThisReferenceExpression(), "Url");
  78. CodeAssignStatement cas = new CodeAssignStatement (ce, new CodePrimitiveExpression (url));
  79. cc.Statements.Add (cas);
  80. codeClass.Members.Add (cc);
  81. memberIds = new CodeIdentifiers ();
  82. headerVariables = new Hashtable ();
  83. return codeClass;
  84. }
  85. protected override void BeginNamespace ()
  86. {
  87. xmlImporter = new XmlSchemaImporter (Schemas, ClassNames);
  88. soapImporter = new SoapSchemaImporter (Schemas, ClassNames);
  89. xmlExporter = new XmlCodeExporter (CodeNamespace, null);
  90. soapExporter = new SoapCodeExporter (CodeNamespace, null);
  91. }
  92. protected override void EndClass ()
  93. {
  94. SoapTransportImporter transportImporter = SoapTransportImporter.FindTransportImporter (soapBinding.Transport);
  95. if (transportImporter == null) throw new InvalidOperationException ("Transport '" + soapBinding.Transport + "' not supported");
  96. transportImporter.ImportContext = this;
  97. transportImporter.ImportClass ();
  98. }
  99. protected override void EndNamespace ()
  100. {
  101. }
  102. protected override bool IsBindingSupported ()
  103. {
  104. return Binding.Extensions.Find (typeof(SoapBinding)) != null;
  105. }
  106. [MonoTODO]
  107. protected override bool IsOperationFlowSupported (OperationFlow flow)
  108. {
  109. throw new NotImplementedException ();
  110. }
  111. protected override CodeMemberMethod GenerateMethod ()
  112. {
  113. try
  114. {
  115. SoapOperationBinding soapOper = OperationBinding.Extensions.Find (typeof (SoapOperationBinding)) as SoapOperationBinding;
  116. if (soapOper == null) throw new InvalidOperationException ("Soap operation binding not found");
  117. SoapBodyBinding isbb = OperationBinding.Input.Extensions.Find (typeof(SoapBodyBinding)) as SoapBodyBinding;
  118. if (isbb == null) throw new InvalidOperationException ("Soap body binding not found");
  119. SoapBodyBinding osbb = OperationBinding.Output.Extensions.Find (typeof(SoapBodyBinding)) as SoapBodyBinding;
  120. if (osbb == null) throw new InvalidOperationException ("Soap body binding not found");
  121. SoapBindingStyle style = soapOper.Style != SoapBindingStyle.Default ? soapOper.Style : soapBinding.Style;
  122. XmlMembersMapping inputMembers = ImportMembersMapping (InputMessage, isbb, style, false);
  123. if (inputMembers == null) throw new InvalidOperationException ("Input message not declared");
  124. XmlMembersMapping outputMembers = ImportMembersMapping (OutputMessage, osbb, style, true);
  125. if (outputMembers == null) throw new InvalidOperationException ("Output message not declared");
  126. CodeMemberMethod met = GenerateMethod (memberIds, soapOper, isbb, inputMembers, outputMembers);
  127. if (isbb.Use == SoapBindingUse.Literal)
  128. xmlExporter.ExportMembersMapping (inputMembers);
  129. else
  130. soapExporter.ExportMembersMapping (inputMembers);
  131. if (osbb.Use == SoapBindingUse.Literal)
  132. xmlExporter.ExportMembersMapping (outputMembers);
  133. else
  134. soapExporter.ExportMembersMapping (outputMembers);
  135. foreach (SoapExtensionImporter eximporter in extensionImporters)
  136. {
  137. eximporter.ImportContext = this;
  138. eximporter.ImportMethod (met.CustomAttributes);
  139. }
  140. return met;
  141. }
  142. catch (InvalidOperationException ex)
  143. {
  144. UnsupportedOperationBindingWarning (ex.Message);
  145. return null;
  146. }
  147. }
  148. XmlMembersMapping ImportMembersMapping (Message msg, SoapBodyBinding sbb, SoapBindingStyle style, bool output)
  149. {
  150. XmlQualifiedName elem = null;
  151. string elemName = Operation.Name;
  152. if (output) elemName += "Response";
  153. if (msg.Parts.Count == 1 && msg.Parts[0].Name == "parameters")
  154. {
  155. // Wrapped parameter style
  156. MessagePart part = msg.Parts[0];
  157. if (sbb.Use == SoapBindingUse.Encoded)
  158. {
  159. SoapSchemaMember ssm = new SoapSchemaMember ();
  160. ssm.MemberName = part.Name;
  161. ssm.MemberType = part.Type;
  162. return soapImporter.ImportMembersMapping (elemName, part.Type.Namespace, ssm);
  163. }
  164. else
  165. return xmlImporter.ImportMembersMapping (part.Element);
  166. }
  167. else
  168. {
  169. if (sbb.Use == SoapBindingUse.Encoded)
  170. {
  171. SoapSchemaMember[] mems = new SoapSchemaMember [msg.Parts.Count];
  172. for (int n=0; n<mems.Length; n++)
  173. {
  174. SoapSchemaMember mem = new SoapSchemaMember();
  175. mem.MemberName = msg.Parts[n].Name;
  176. mem.MemberType = msg.Parts[n].Type;
  177. mems[n] = mem;
  178. }
  179. // Rpc messages always have a wrapping element
  180. if (style == SoapBindingStyle.Rpc)
  181. return soapImporter.ImportMembersMapping (elemName, sbb.Namespace, mems, true);
  182. else
  183. return soapImporter.ImportMembersMapping ("", "", mems, false);
  184. }
  185. else
  186. {
  187. if (style == SoapBindingStyle.Rpc)
  188. throw new InvalidOperationException ("The combination of style=rpc with use=literal is not supported");
  189. XmlQualifiedName[] pnames = new XmlQualifiedName [msg.Parts.Count];
  190. for (int n=0; n<pnames.Length; n++)
  191. pnames[n] = msg.Parts[n].Element;
  192. return xmlImporter.ImportMembersMapping (pnames);
  193. }
  194. }
  195. }
  196. CodeMemberMethod GenerateMethod (CodeIdentifiers memberIds, SoapOperationBinding soapOper, SoapBodyBinding bodyBinding, XmlMembersMapping inputMembers, XmlMembersMapping outputMembers)
  197. {
  198. CodeIdentifiers pids = new CodeIdentifiers ();
  199. CodeMemberMethod method = new CodeMemberMethod ();
  200. CodeMemberMethod methodBegin = new CodeMemberMethod ();
  201. CodeMemberMethod methodEnd = new CodeMemberMethod ();
  202. method.Attributes = MemberAttributes.Public;
  203. methodBegin.Attributes = MemberAttributes.Public;
  204. methodEnd.Attributes = MemberAttributes.Public;
  205. SoapBindingStyle style = soapOper.Style != SoapBindingStyle.Default ? soapOper.Style : soapBinding.Style;
  206. // Find unique names for temporary variables
  207. for (int n=0; n<inputMembers.Count; n++)
  208. pids.AddUnique (inputMembers[n].MemberName, inputMembers[n]);
  209. for (int n=0; n<outputMembers.Count; n++)
  210. pids.AddUnique (outputMembers[n].MemberName, outputMembers[n]);
  211. string varAsyncResult = pids.AddUnique ("asyncResult","asyncResult");
  212. string varResults = pids.AddUnique ("results","results");
  213. string varCallback = pids.AddUnique ("callback","callback");
  214. string varAsyncState = pids.AddUnique ("asyncState","asyncState");
  215. string messageName = memberIds.AddUnique(CodeIdentifier.MakeValid(Operation.Name),method);
  216. method.Name = CodeIdentifier.MakeValid(Operation.Name);
  217. if (method.Name == ClassName) method.Name += "1";
  218. methodBegin.Name = memberIds.AddUnique(CodeIdentifier.MakeValid("Begin" + memberIds.MakeRightCase(method.Name)),method);
  219. methodEnd.Name = memberIds.AddUnique(CodeIdentifier.MakeValid("End" + memberIds.MakeRightCase(method.Name)),method);
  220. method.ReturnType = new CodeTypeReference (typeof(void));
  221. methodEnd.ReturnType = new CodeTypeReference (typeof(void));
  222. methodEnd.Parameters.Add (new CodeParameterDeclarationExpression (typeof (IAsyncResult),varAsyncResult));
  223. CodeExpression[] paramArray = new CodeExpression [inputMembers.Count];
  224. CodeParameterDeclarationExpression[] outParams = new CodeParameterDeclarationExpression [outputMembers.Count];
  225. for (int n=0; n<inputMembers.Count; n++)
  226. {
  227. CodeParameterDeclarationExpression param = GenerateParameter (inputMembers[n], FieldDirection.In);
  228. method.Parameters.Add (param);
  229. GenerateMemberAttributes (inputMembers, inputMembers[n], bodyBinding.Use, param);
  230. methodBegin.Parameters.Add (GenerateParameter (inputMembers[n], FieldDirection.In));
  231. paramArray [n] = new CodeVariableReferenceExpression (param.Name);
  232. }
  233. for (int n=0; n<outputMembers.Count; n++)
  234. {
  235. CodeParameterDeclarationExpression cpd = GenerateParameter (outputMembers[n], FieldDirection.Out);
  236. outParams [n] = cpd;
  237. bool found = false;
  238. foreach (CodeParameterDeclarationExpression ip in method.Parameters)
  239. {
  240. if (ip.Name == cpd.Name && ip.Type.BaseType == cpd.Type.BaseType) {
  241. ip.Direction = FieldDirection.Ref;
  242. methodEnd.Parameters.Add (GenerateParameter (outputMembers[n], FieldDirection.Out));
  243. found = true;
  244. break;
  245. }
  246. }
  247. if (found) continue;
  248. if ((outputMembers [n].ElementName == Operation.Name + "Result") ||
  249. (outputMembers.Count==1))
  250. {
  251. method.ReturnType = cpd.Type;
  252. methodEnd.ReturnType = cpd.Type;
  253. GenerateReturnAttributes (outputMembers, outputMembers[n], bodyBinding.Use, method);
  254. outParams [n] = null;
  255. continue;
  256. }
  257. method.Parameters.Add (cpd);
  258. GenerateMemberAttributes (outputMembers, outputMembers[n], bodyBinding.Use, cpd);
  259. methodEnd.Parameters.Add (GenerateParameter (outputMembers[n], FieldDirection.Out));
  260. }
  261. methodBegin.Parameters.Add (new CodeParameterDeclarationExpression (typeof (AsyncCallback),varCallback));
  262. methodBegin.Parameters.Add (new CodeParameterDeclarationExpression (typeof (object),varAsyncState));
  263. methodBegin.ReturnType = new CodeTypeReference (typeof(IAsyncResult));
  264. // Array of input parameters
  265. CodeArrayCreateExpression methodParams;
  266. if (paramArray.Length > 0)
  267. methodParams = new CodeArrayCreateExpression (typeof(object), paramArray);
  268. else
  269. methodParams = new CodeArrayCreateExpression (typeof(object), 0);
  270. // Assignment of output parameters
  271. CodeStatementCollection outAssign = new CodeStatementCollection ();
  272. CodeVariableReferenceExpression arrVar = new CodeVariableReferenceExpression (varResults);
  273. for (int n=0; n<outParams.Length; n++)
  274. {
  275. CodeExpression index = new CodePrimitiveExpression (n);
  276. if (outParams[n] == null)
  277. {
  278. CodeExpression res = new CodeCastExpression (method.ReturnType, new CodeArrayIndexerExpression (arrVar, index));
  279. outAssign.Add (new CodeMethodReturnStatement (res));
  280. }
  281. else
  282. {
  283. CodeExpression res = new CodeCastExpression (outParams[n].Type, new CodeArrayIndexerExpression (arrVar, index));
  284. CodeExpression var = new CodeVariableReferenceExpression (outParams[n].Name);
  285. outAssign.Insert (0, new CodeAssignStatement (var, res));
  286. }
  287. }
  288. // Invoke call
  289. CodeThisReferenceExpression ethis = new CodeThisReferenceExpression();
  290. CodePrimitiveExpression varMsgName = new CodePrimitiveExpression (messageName);
  291. CodeMethodInvokeExpression inv;
  292. CodeVariableDeclarationStatement dec;
  293. inv = new CodeMethodInvokeExpression (ethis, "Invoke", varMsgName, methodParams);
  294. if (outputMembers.Count > 0)
  295. {
  296. dec = new CodeVariableDeclarationStatement (typeof(object[]), varResults, inv);
  297. method.Statements.Add (dec);
  298. method.Statements.AddRange (outAssign);
  299. }
  300. else
  301. method.Statements.Add (inv);
  302. // Begin Invoke Call
  303. CodeExpression expCallb = new CodeVariableReferenceExpression (varCallback);
  304. CodeExpression expAsyncs = new CodeVariableReferenceExpression (varAsyncState);
  305. inv = new CodeMethodInvokeExpression (ethis, "BeginInvoke", varMsgName, methodParams, expCallb, expAsyncs);
  306. methodBegin.Statements.Add (new CodeMethodReturnStatement (inv));
  307. // End Invoke call
  308. CodeExpression varAsyncr = new CodeVariableReferenceExpression (varAsyncResult);
  309. inv = new CodeMethodInvokeExpression (ethis, "EndInvoke", varAsyncr);
  310. if (outputMembers.Count > 0)
  311. {
  312. dec = new CodeVariableDeclarationStatement (typeof(object[]), varResults, inv);
  313. methodEnd.Statements.Add (dec);
  314. methodEnd.Statements.AddRange (outAssign);
  315. }
  316. else
  317. methodEnd.Statements.Add (inv);
  318. // Attributes
  319. ImportHeaders (method);
  320. CodeAttributeDeclaration att = new CodeAttributeDeclaration ("System.Web.Services.WebMethodAttribute");
  321. if (messageName != method.Name) att.Arguments.Add (GetArg ("MessageName",messageName));
  322. AddCustomAttribute (method, att, false);
  323. if (style == SoapBindingStyle.Rpc)
  324. {
  325. att = new CodeAttributeDeclaration ("System.Web.Services.Protocols.SoapRpcMethodAttribute");
  326. att.Arguments.Add (GetArg (soapOper.SoapAction));
  327. if (inputMembers.ElementName != method.Name) att.Arguments.Add (GetArg ("RequestElementName", inputMembers.ElementName));
  328. if (outputMembers.ElementName != (method.Name + "Response")) att.Arguments.Add (GetArg ("ResponseElementName", outputMembers.ElementName));
  329. att.Arguments.Add (GetArg ("RequestNamespace", inputMembers.Namespace));
  330. att.Arguments.Add (GetArg ("ResponseNamespace", outputMembers.Namespace));
  331. }
  332. else
  333. {
  334. if (inputMembers.ElementName == "" && outputMembers.ElementName != "" ||
  335. inputMembers.ElementName != "" && outputMembers.ElementName == "")
  336. throw new InvalidOperationException ("Parameter style is not the same for the input message and output message");
  337. att = new CodeAttributeDeclaration ("System.Web.Services.Protocols.SoapDocumentMethodAttribute");
  338. att.Arguments.Add (GetArg (soapOper.SoapAction));
  339. if (inputMembers.ElementName != "") {
  340. if (inputMembers.ElementName != method.Name) att.Arguments.Add (GetArg ("RequestElementName", inputMembers.ElementName));
  341. if (outputMembers.ElementName != (method.Name + "Response")) att.Arguments.Add (GetArg ("ResponseElementName", outputMembers.ElementName));
  342. att.Arguments.Add (GetArg ("RequestNamespace", inputMembers.Namespace));
  343. att.Arguments.Add (GetArg ("ResponseNamespace", outputMembers.Namespace));
  344. att.Arguments.Add (GetEnumArg ("ParameterStyle", "System.Web.Services.Protocols.SoapParameterStyle", "Wrapped"));
  345. }
  346. else
  347. att.Arguments.Add (GetEnumArg ("ParameterStyle", "System.Web.Services.Protocols.SoapParameterStyle", "Bare"));
  348. att.Arguments.Add (GetEnumArg ("Use", "System.Web.Services.Description.SoapBindingUse", bodyBinding.Use.ToString()));
  349. }
  350. AddCustomAttribute (method, att, true);
  351. CodeTypeDeclaration.Members.Add (method);
  352. CodeTypeDeclaration.Members.Add (methodBegin);
  353. CodeTypeDeclaration.Members.Add (methodEnd);
  354. return method;
  355. }
  356. CodeParameterDeclarationExpression GenerateParameter (XmlMemberMapping member, FieldDirection dir)
  357. {
  358. CodeParameterDeclarationExpression par = new CodeParameterDeclarationExpression (member.TypeFullName, member.MemberName);
  359. par.Direction = dir;
  360. return par;
  361. }
  362. void GenerateMemberAttributes (XmlMembersMapping members, XmlMemberMapping member, SoapBindingUse use, CodeParameterDeclarationExpression param)
  363. {
  364. if (use == SoapBindingUse.Literal)
  365. xmlExporter.AddMappingMetadata (param.CustomAttributes, member, members.Namespace);
  366. else
  367. soapExporter.AddMappingMetadata (param.CustomAttributes, member);
  368. }
  369. void GenerateReturnAttributes (XmlMembersMapping members, XmlMemberMapping member, SoapBindingUse use, CodeMemberMethod method)
  370. {
  371. if (use == SoapBindingUse.Literal)
  372. xmlExporter.AddMappingMetadata (method.ReturnTypeCustomAttributes, member, members.Namespace, (member.ElementName != method.Name + "Result"));
  373. else
  374. soapExporter.AddMappingMetadata (method.ReturnTypeCustomAttributes, member, (member.ElementName != method.Name + "Result"));
  375. }
  376. void ImportHeaders (CodeMemberMethod method)
  377. {
  378. foreach (object ob in OperationBinding.Input.Extensions)
  379. {
  380. SoapHeaderBinding hb = ob as SoapHeaderBinding;
  381. if (hb == null) continue;
  382. if (HasHeader (OperationBinding.Output, hb))
  383. ImportHeader (method, hb, SoapHeaderDirection.In | SoapHeaderDirection.Out);
  384. else
  385. ImportHeader (method, hb, SoapHeaderDirection.In);
  386. }
  387. foreach (object ob in OperationBinding.Output.Extensions)
  388. {
  389. SoapHeaderBinding hb = ob as SoapHeaderBinding;
  390. if (hb == null) continue;
  391. if (!HasHeader (OperationBinding.Input, hb))
  392. ImportHeader (method, hb, SoapHeaderDirection.Out);
  393. }
  394. }
  395. bool HasHeader (MessageBinding msg, SoapHeaderBinding hb)
  396. {
  397. foreach (object ob in msg.Extensions)
  398. {
  399. SoapHeaderBinding mhb = ob as SoapHeaderBinding;
  400. if ((mhb != null) && (mhb.Message == hb.Message) && (mhb.Part == hb.Part))
  401. return true;
  402. }
  403. return false;
  404. }
  405. void ImportHeader (CodeMemberMethod method, SoapHeaderBinding hb, SoapHeaderDirection direction)
  406. {
  407. Message msg = ServiceDescriptions.GetMessage (hb.Message);
  408. if (msg == null) throw new InvalidOperationException ("Message " + hb.Message + " not found");
  409. MessagePart part = msg.Parts [hb.Part];
  410. if (part == null) throw new InvalidOperationException ("Message part " + hb.Part + " not found in message " + hb.Message);
  411. XmlTypeMapping map;
  412. if (hb.Use == SoapBindingUse.Literal)
  413. {
  414. map = xmlImporter.ImportDerivedTypeMapping (part.Element, typeof (SoapHeader));
  415. xmlExporter.ExportTypeMapping (map);
  416. }
  417. else
  418. {
  419. map = soapImporter.ImportDerivedTypeMapping (part.Type, typeof (SoapHeader), true);
  420. soapExporter.ExportTypeMapping (map);
  421. }
  422. bool required = false;
  423. string varName = headerVariables [map] as string;
  424. if (varName == null)
  425. {
  426. varName = memberIds.AddUnique(CodeIdentifier.MakeValid (hb.Part + "Value"),hb);
  427. headerVariables.Add (map, varName);
  428. CodeMemberField codeField = new CodeMemberField (map.TypeFullName, varName);
  429. codeField.Attributes = MemberAttributes.Public;
  430. CodeTypeDeclaration.Members.Add (codeField);
  431. }
  432. CodeAttributeDeclaration att = new CodeAttributeDeclaration ("System.Web.Services.Protocols.SoapHeaderAttribute");
  433. att.Arguments.Add (GetArg (varName));
  434. att.Arguments.Add (GetArg ("Required", required));
  435. if (direction != SoapHeaderDirection.In) att.Arguments.Add (GetEnumArg ("Direction", "System.Web.Services.Protocols.SoapHeaderDirection", direction.ToString ()));
  436. AddCustomAttribute (method, att, true);
  437. }
  438. #endregion
  439. }
  440. }