2 // System.Web.Services.Description.SoapProtocolImporter.cs
5 // Tim Coleman (tim@timcoleman.com)
6 // Lluis Sanchez Gual (lluis@ximian.com)
8 // Copyright (C) Tim Coleman, 2002
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 using System.Web.Services;
34 using System.Web.Services.Protocols;
35 using System.Web.Services.Configuration;
37 using System.Xml.Schema;
38 using System.Xml.Serialization;
39 using System.Configuration;
40 using System.Collections;
42 namespace System.Web.Services.Description {
43 public class SoapProtocolImporter : ProtocolImporter {
47 SoapBinding soapBinding;
48 SoapCodeExporter soapExporter;
49 SoapSchemaImporter soapImporter;
50 XmlCodeExporter xmlExporter;
51 XmlSchemaImporter xmlImporter;
52 CodeIdentifiers memberIds;
53 ArrayList extensionImporters;
54 Hashtable headerVariables;
55 XmlSchemas xmlSchemas;
56 XmlSchemas soapSchemas;
62 public SoapProtocolImporter ()
64 extensionImporters = ExtensionManager.BuildExtensionImporters ();
67 void SetBinding (SoapBinding soapBinding)
69 this.soapBinding = soapBinding;
72 #endregion // Constructors
76 public override string ProtocolName {
77 get { return "Soap"; }
80 public SoapBinding SoapBinding {
81 get { return soapBinding; }
84 public SoapCodeExporter SoapExporter {
85 get { return soapExporter; }
88 public SoapSchemaImporter SoapImporter {
89 get { return soapImporter; }
92 public XmlCodeExporter XmlExporter {
93 get { return xmlExporter; }
96 public XmlSchemaImporter XmlImporter {
97 get { return xmlImporter; }
100 #endregion // Properties
104 protected override CodeTypeDeclaration BeginClass ()
106 soapBinding = (SoapBinding) Binding.Extensions.Find (typeof(SoapBinding));
108 CodeTypeDeclaration codeClass = new CodeTypeDeclaration (ClassName);
110 string location = null;
113 SoapAddressBinding sab = (SoapAddressBinding) Port.Extensions.Find (typeof(SoapAddressBinding));
114 if (sab != null) location = sab.Location;
117 string namspace = (Port != null ? Port.Binding.Namespace : Binding.ServiceDescription.TargetNamespace);
118 string name = (Port != null ? Port.Name : Binding.Name);
120 if (Style == ServiceDescriptionImportStyle.Client) {
121 CodeTypeReference ctr = new CodeTypeReference ("System.Web.Services.Protocols.SoapHttpClientProtocol");
122 codeClass.BaseTypes.Add (ctr);
125 CodeTypeReference ctr = new CodeTypeReference ("System.Web.Services.WebService");
126 codeClass.BaseTypes.Add (ctr);
127 CodeAttributeDeclaration attws = new CodeAttributeDeclaration ("System.Web.Services.WebServiceAttribute");
128 attws.Arguments.Add (GetArg ("Namespace", namspace));
129 AddCustomAttribute (codeClass, attws, true);
132 CodeAttributeDeclaration att = new CodeAttributeDeclaration ("System.Web.Services.WebServiceBinding");
133 att.Arguments.Add (GetArg ("Name", name));
134 att.Arguments.Add (GetArg ("Namespace", namspace));
135 AddCustomAttribute (codeClass, att, true);
137 if (Style == ServiceDescriptionImportStyle.Client) {
138 CodeConstructor cc = new CodeConstructor ();
139 cc.Attributes = MemberAttributes.Public;
140 GenerateServiceUrl (location, cc.Statements);
141 codeClass.Members.Add (cc);
144 memberIds = new CodeIdentifiers ();
145 headerVariables = new Hashtable ();
149 protected override void BeginNamespace ()
152 xmlImporter = new XmlSchemaImporter (LiteralSchemas, base.CodeGenerationOptions, base.CodeGenerator, base.ImportContext);
153 soapImporter = new SoapSchemaImporter (EncodedSchemas, base.CodeGenerationOptions, base.CodeGenerator, base.ImportContext);
154 xmlExporter = new XmlCodeExporter (CodeNamespace, null, base.CodeGenerator, base.CodeGenerationOptions, null);
155 soapExporter = new SoapCodeExporter (CodeNamespace, null, base.CodeGenerator, base.CodeGenerationOptions, null);
157 xmlImporter = new XmlSchemaImporter (LiteralSchemas, ClassNames);
158 soapImporter = new SoapSchemaImporter (EncodedSchemas, ClassNames);
159 xmlExporter = new XmlCodeExporter (CodeNamespace, null);
160 soapExporter = new SoapCodeExporter (CodeNamespace, null);
164 protected override void EndClass ()
166 SoapTransportImporter transportImporter = SoapTransportImporter.FindTransportImporter (soapBinding.Transport);
167 if (transportImporter == null) throw new InvalidOperationException ("Transport '" + soapBinding.Transport + "' not supported");
168 transportImporter.ImportContext = this;
169 transportImporter.ImportClass ();
171 if (xmlExporter.IncludeMetadata.Count > 0 || soapExporter.IncludeMetadata.Count > 0)
173 if (CodeTypeDeclaration.CustomAttributes == null)
174 CodeTypeDeclaration.CustomAttributes = new CodeAttributeDeclarationCollection ();
175 CodeTypeDeclaration.CustomAttributes.AddRange (xmlExporter.IncludeMetadata);
176 CodeTypeDeclaration.CustomAttributes.AddRange (soapExporter.IncludeMetadata);
180 protected override void EndNamespace ()
184 protected override bool IsBindingSupported ()
186 return Binding.Extensions.Find (typeof(SoapBinding)) != null;
190 protected override bool IsOperationFlowSupported (OperationFlow flow)
192 throw new NotImplementedException ();
195 static readonly char [] whitespaces = new char [] {' ', '\t', '\n', '\r'};
197 protected virtual bool IsSoapEncodingPresent (string uriList)
199 foreach (string s in uriList.Split (whitespaces))
200 if (s == "http://schemas.xmlsoap.org/soap/encoding/")
205 protected override CodeMemberMethod GenerateMethod ()
209 SoapOperationBinding soapOper = OperationBinding.Extensions.Find (typeof (SoapOperationBinding)) as SoapOperationBinding;
210 if (soapOper == null) throw new InvalidOperationException ("Soap operation binding not found");
212 SoapBindingStyle style = soapOper.Style != SoapBindingStyle.Default ? soapOper.Style : soapBinding.Style;
214 SoapBodyBinding isbb = null;
215 XmlMembersMapping inputMembers = null;
217 bool isWrapped = CheckIsWrapped ();
219 isbb = OperationBinding.Input.Extensions.Find (typeof(SoapBodyBinding)) as SoapBodyBinding;
220 if (isbb == null) throw new InvalidOperationException ("Soap body binding not found");
222 inputMembers = ImportMembersMapping (InputMessage, isbb, style, false, isWrapped);
223 if (inputMembers == null) throw new InvalidOperationException ("Input message not declared");
225 // If OperationBinding.Output is null, it is an OneWay operation
227 SoapBodyBinding osbb = null;
228 XmlMembersMapping outputMembers = null;
230 if (OperationBinding.Output != null) {
231 osbb = OperationBinding.Output.Extensions.Find (typeof(SoapBodyBinding)) as SoapBodyBinding;
232 if (osbb == null) throw new InvalidOperationException ("Soap body binding not found");
234 outputMembers = ImportMembersMapping (OutputMessage, osbb, style, true, isWrapped);
235 if (outputMembers == null) throw new InvalidOperationException ("Output message not declared");
238 CodeMemberMethod met = GenerateMethod (memberIds, soapOper, isbb, inputMembers, outputMembers);
240 if (isbb.Use == SoapBindingUse.Literal)
241 xmlExporter.ExportMembersMapping (inputMembers);
243 soapExporter.ExportMembersMapping (inputMembers);
246 if (osbb.Use == SoapBindingUse.Literal)
247 xmlExporter.ExportMembersMapping (outputMembers);
249 soapExporter.ExportMembersMapping (outputMembers);
252 foreach (SoapExtensionImporter eximporter in extensionImporters)
254 eximporter.ImportContext = this;
255 eximporter.ImportMethod (met.CustomAttributes);
260 catch (InvalidOperationException ex)
262 UnsupportedOperationBindingWarning (ex.Message);
267 bool CheckIsWrapped ()
269 return (OutputMessage == null || (OutputMessage.Parts.Count == 1 && OutputMessage.Parts[0].Name == "parameters")) &&
270 (InputMessage == null || (InputMessage.Parts.Count == 1 && InputMessage.Parts[0].Name == "parameters"));
273 XmlMembersMapping ImportMembersMapping (Message msg, SoapBodyBinding sbb, SoapBindingStyle style, bool output, bool wrapped)
275 string elemName = Operation.Name;
276 if (output) elemName += "Response";
280 // Wrapped parameter style
282 MessagePart part = msg.Parts[0];
283 if (sbb.Use == SoapBindingUse.Encoded)
285 SoapSchemaMember ssm = new SoapSchemaMember ();
286 ssm.MemberName = part.Name;
287 ssm.MemberType = part.Type;
288 return soapImporter.ImportMembersMapping (elemName, part.Type.Namespace, ssm);
291 return xmlImporter.ImportMembersMapping (part.Element);
295 if (sbb.Use == SoapBindingUse.Encoded)
297 SoapSchemaMember[] mems = new SoapSchemaMember [msg.Parts.Count];
298 for (int n=0; n<mems.Length; n++)
300 SoapSchemaMember mem = new SoapSchemaMember();
301 mem.MemberName = msg.Parts[n].Name;
302 mem.MemberType = msg.Parts[n].Type;
306 // Rpc messages always have a wrapping element
307 if (style == SoapBindingStyle.Rpc)
308 return soapImporter.ImportMembersMapping (elemName, sbb.Namespace, mems, true);
310 return soapImporter.ImportMembersMapping ("", "", mems, false);
314 if (style == SoapBindingStyle.Rpc)
315 throw new InvalidOperationException ("The combination of style=rpc with use=literal is not supported");
317 if (msg.Parts.Count == 1 && msg.Parts[0].Type != XmlQualifiedName.Empty)
318 return xmlImporter.ImportAnyType (msg.Parts[0].Type, null);
321 XmlQualifiedName[] pnames = new XmlQualifiedName [msg.Parts.Count];
322 for (int n=0; n<pnames.Length; n++)
323 pnames[n] = msg.Parts[n].Element;
324 return xmlImporter.ImportMembersMapping (pnames);
330 CodeMemberMethod GenerateMethod (CodeIdentifiers memberIds, SoapOperationBinding soapOper, SoapBodyBinding bodyBinding, XmlMembersMapping inputMembers, XmlMembersMapping outputMembers)
332 CodeIdentifiers pids = new CodeIdentifiers ();
333 CodeMemberMethod method = new CodeMemberMethod ();
334 CodeMemberMethod methodBegin = new CodeMemberMethod ();
335 CodeMemberMethod methodEnd = new CodeMemberMethod ();
336 method.Attributes = MemberAttributes.Public | MemberAttributes.Final;
337 methodBegin.Attributes = MemberAttributes.Public | MemberAttributes.Final;
338 methodEnd.Attributes = MemberAttributes.Public | MemberAttributes.Final;
340 SoapBindingStyle style = soapOper.Style != SoapBindingStyle.Default ? soapOper.Style : soapBinding.Style;
342 // Find unique names for temporary variables
344 for (int n=0; n<inputMembers.Count; n++)
345 pids.AddUnique (inputMembers[n].MemberName, inputMembers[n]);
347 if (outputMembers != null)
348 for (int n=0; n<outputMembers.Count; n++)
349 pids.AddUnique (outputMembers[n].MemberName, outputMembers[n]);
351 string varAsyncResult = pids.AddUnique ("asyncResult","asyncResult");
352 string varResults = pids.AddUnique ("results","results");
353 string varCallback = pids.AddUnique ("callback","callback");
354 string varAsyncState = pids.AddUnique ("asyncState","asyncState");
356 string messageName = memberIds.AddUnique(CodeIdentifier.MakeValid(Operation.Name),method);
358 method.Name = CodeIdentifier.MakeValid(Operation.Name);
359 if (method.Name == ClassName) method.Name += "1";
360 methodBegin.Name = memberIds.AddUnique(CodeIdentifier.MakeValid("Begin" + method.Name),method);
361 methodEnd.Name = memberIds.AddUnique(CodeIdentifier.MakeValid("End" + method.Name),method);
363 method.ReturnType = new CodeTypeReference (typeof(void));
364 methodEnd.ReturnType = new CodeTypeReference (typeof(void));
365 methodEnd.Parameters.Add (new CodeParameterDeclarationExpression (typeof (IAsyncResult),varAsyncResult));
367 CodeExpression[] paramArray = new CodeExpression [inputMembers.Count];
368 CodeParameterDeclarationExpression[] outParams = new CodeParameterDeclarationExpression [outputMembers != null ? outputMembers.Count : 0];
370 for (int n=0; n<inputMembers.Count; n++)
372 CodeParameterDeclarationExpression param = GenerateParameter (inputMembers[n], FieldDirection.In);
373 method.Parameters.Add (param);
374 GenerateMemberAttributes (inputMembers, inputMembers[n], bodyBinding.Use, param);
375 methodBegin.Parameters.Add (GenerateParameter (inputMembers[n], FieldDirection.In));
376 paramArray [n] = new CodeVariableReferenceExpression (param.Name);
379 if (outputMembers != null)
381 bool hasReturn = false;
382 for (int n=0; n<outputMembers.Count; n++)
384 CodeParameterDeclarationExpression cpd = GenerateParameter (outputMembers[n], FieldDirection.Out);
388 foreach (CodeParameterDeclarationExpression ip in method.Parameters)
390 if (ip.Name == cpd.Name && ip.Type.BaseType == cpd.Type.BaseType) {
391 ip.Direction = FieldDirection.Ref;
392 methodEnd.Parameters.Add (GenerateParameter (outputMembers[n], FieldDirection.Out));
403 method.ReturnType = cpd.Type;
404 methodEnd.ReturnType = cpd.Type;
405 GenerateReturnAttributes (outputMembers, outputMembers[n], bodyBinding.Use, method);
406 outParams [n] = null;
410 method.Parameters.Add (cpd);
411 GenerateMemberAttributes (outputMembers, outputMembers[n], bodyBinding.Use, cpd);
412 methodEnd.Parameters.Add (GenerateParameter (outputMembers[n], FieldDirection.Out));
416 methodBegin.Parameters.Add (new CodeParameterDeclarationExpression (typeof (AsyncCallback),varCallback));
417 methodBegin.Parameters.Add (new CodeParameterDeclarationExpression (typeof (object),varAsyncState));
418 methodBegin.ReturnType = new CodeTypeReference (typeof(IAsyncResult));
420 // Array of input parameters
422 CodeArrayCreateExpression methodParams;
423 if (paramArray.Length > 0)
424 methodParams = new CodeArrayCreateExpression (typeof(object), paramArray);
426 methodParams = new CodeArrayCreateExpression (typeof(object), 0);
428 // Assignment of output parameters
430 CodeStatementCollection outAssign = new CodeStatementCollection ();
431 CodeVariableReferenceExpression arrVar = new CodeVariableReferenceExpression (varResults);
432 for (int n=0; n<outParams.Length; n++)
434 CodeExpression index = new CodePrimitiveExpression (n);
435 if (outParams[n] == null)
437 CodeExpression res = new CodeCastExpression (method.ReturnType, new CodeArrayIndexerExpression (arrVar, index));
438 outAssign.Add (new CodeMethodReturnStatement (res));
442 CodeExpression res = new CodeCastExpression (outParams[n].Type, new CodeArrayIndexerExpression (arrVar, index));
443 CodeExpression var = new CodeVariableReferenceExpression (outParams[n].Name);
444 outAssign.Insert (0, new CodeAssignStatement (var, res));
448 if (Style == ServiceDescriptionImportStyle.Client)
452 CodeThisReferenceExpression ethis = new CodeThisReferenceExpression();
453 CodePrimitiveExpression varMsgName = new CodePrimitiveExpression (messageName);
454 CodeMethodInvokeExpression inv;
455 CodeVariableDeclarationStatement dec;
457 inv = new CodeMethodInvokeExpression (ethis, "Invoke", varMsgName, methodParams);
458 if (outputMembers != null && outputMembers.Count > 0)
460 dec = new CodeVariableDeclarationStatement (typeof(object[]), varResults, inv);
461 method.Statements.Add (dec);
462 method.Statements.AddRange (outAssign);
465 method.Statements.Add (inv);
469 CodeExpression expCallb = new CodeVariableReferenceExpression (varCallback);
470 CodeExpression expAsyncs = new CodeVariableReferenceExpression (varAsyncState);
471 inv = new CodeMethodInvokeExpression (ethis, "BeginInvoke", varMsgName, methodParams, expCallb, expAsyncs);
472 methodBegin.Statements.Add (new CodeMethodReturnStatement (inv));
476 CodeExpression varAsyncr = new CodeVariableReferenceExpression (varAsyncResult);
477 inv = new CodeMethodInvokeExpression (ethis, "EndInvoke", varAsyncr);
478 if (outputMembers != null && outputMembers.Count > 0)
480 dec = new CodeVariableDeclarationStatement (typeof(object[]), varResults, inv);
481 methodEnd.Statements.Add (dec);
482 methodEnd.Statements.AddRange (outAssign);
485 methodEnd.Statements.Add (inv);
488 method.Attributes = MemberAttributes.Public | MemberAttributes.Abstract;
493 ImportHeaders (method);
495 CodeAttributeDeclaration att = new CodeAttributeDeclaration ("System.Web.Services.WebMethodAttribute");
496 if (messageName != method.Name) att.Arguments.Add (GetArg ("MessageName",messageName));
497 AddCustomAttribute (method, att, (Style == ServiceDescriptionImportStyle.Server));
499 if (style == SoapBindingStyle.Rpc)
501 att = new CodeAttributeDeclaration ("System.Web.Services.Protocols.SoapRpcMethodAttribute");
502 att.Arguments.Add (GetArg (soapOper.SoapAction));
503 if (inputMembers.ElementName != method.Name) att.Arguments.Add (GetArg ("RequestElementName", inputMembers.ElementName));
504 if (outputMembers != null && outputMembers.ElementName != (method.Name + "Response")) att.Arguments.Add (GetArg ("ResponseElementName", outputMembers.ElementName));
505 att.Arguments.Add (GetArg ("RequestNamespace", inputMembers.Namespace));
506 if (outputMembers != null) att.Arguments.Add (GetArg ("ResponseNamespace", outputMembers.Namespace));
507 if (outputMembers == null) att.Arguments.Add (GetArg ("OneWay", true));
511 if (outputMembers != null && (inputMembers.ElementName == "" && outputMembers.ElementName != "" ||
512 inputMembers.ElementName != "" && outputMembers.ElementName == ""))
513 throw new InvalidOperationException ("Parameter style is not the same for the input message and output message");
515 att = new CodeAttributeDeclaration ("System.Web.Services.Protocols.SoapDocumentMethodAttribute");
516 att.Arguments.Add (GetArg (soapOper.SoapAction));
517 if (inputMembers.ElementName != "") {
518 if (inputMembers.ElementName != method.Name) att.Arguments.Add (GetArg ("RequestElementName", inputMembers.ElementName));
519 if (outputMembers != null && outputMembers.ElementName != (method.Name + "Response")) att.Arguments.Add (GetArg ("ResponseElementName", outputMembers.ElementName));
520 att.Arguments.Add (GetArg ("RequestNamespace", inputMembers.Namespace));
521 if (outputMembers != null) att.Arguments.Add (GetArg ("ResponseNamespace", outputMembers.Namespace));
522 att.Arguments.Add (GetEnumArg ("ParameterStyle", "System.Web.Services.Protocols.SoapParameterStyle", "Wrapped"));
525 att.Arguments.Add (GetEnumArg ("ParameterStyle", "System.Web.Services.Protocols.SoapParameterStyle", "Bare"));
527 if (outputMembers == null) att.Arguments.Add (GetArg ("OneWay", true));
529 att.Arguments.Add (GetEnumArg ("Use", "System.Web.Services.Description.SoapBindingUse", bodyBinding.Use.ToString()));
532 AddCustomAttribute (method, att, true);
534 CodeTypeDeclaration.Members.Add (method);
536 if (Style == ServiceDescriptionImportStyle.Client) {
537 CodeTypeDeclaration.Members.Add (methodBegin);
538 CodeTypeDeclaration.Members.Add (methodEnd);
544 CodeParameterDeclarationExpression GenerateParameter (XmlMemberMapping member, FieldDirection dir)
546 CodeParameterDeclarationExpression par = new CodeParameterDeclarationExpression (member.TypeFullName, member.MemberName);
551 void GenerateMemberAttributes (XmlMembersMapping members, XmlMemberMapping member, SoapBindingUse use, CodeParameterDeclarationExpression param)
553 if (use == SoapBindingUse.Literal)
554 xmlExporter.AddMappingMetadata (param.CustomAttributes, member, members.Namespace);
556 soapExporter.AddMappingMetadata (param.CustomAttributes, member);
559 void GenerateReturnAttributes (XmlMembersMapping members, XmlMemberMapping member, SoapBindingUse use, CodeMemberMethod method)
561 if (use == SoapBindingUse.Literal)
562 xmlExporter.AddMappingMetadata (method.ReturnTypeCustomAttributes, member, members.Namespace, (member.ElementName != method.Name + "Result"));
564 soapExporter.AddMappingMetadata (method.ReturnTypeCustomAttributes, member, (member.ElementName != method.Name + "Result"));
567 void ImportHeaders (CodeMemberMethod method)
569 foreach (object ob in OperationBinding.Input.Extensions)
571 SoapHeaderBinding hb = ob as SoapHeaderBinding;
572 if (hb == null) continue;
573 if (HasHeader (OperationBinding.Output, hb))
574 ImportHeader (method, hb, SoapHeaderDirection.In | SoapHeaderDirection.Out);
576 ImportHeader (method, hb, SoapHeaderDirection.In);
579 if (OperationBinding.Output == null) return;
581 foreach (object ob in OperationBinding.Output.Extensions)
583 SoapHeaderBinding hb = ob as SoapHeaderBinding;
584 if (hb == null) continue;
585 if (!HasHeader (OperationBinding.Input, hb))
586 ImportHeader (method, hb, SoapHeaderDirection.Out);
590 bool HasHeader (MessageBinding msg, SoapHeaderBinding hb)
592 if (msg == null) return false;
594 foreach (object ob in msg.Extensions)
596 SoapHeaderBinding mhb = ob as SoapHeaderBinding;
597 if ((mhb != null) && (mhb.Message == hb.Message) && (mhb.Part == hb.Part))
603 void ImportHeader (CodeMemberMethod method, SoapHeaderBinding hb, SoapHeaderDirection direction)
605 Message msg = ServiceDescriptions.GetMessage (hb.Message);
606 if (msg == null) throw new InvalidOperationException ("Message " + hb.Message + " not found");
607 MessagePart part = msg.Parts [hb.Part];
608 if (part == null) throw new InvalidOperationException ("Message part " + hb.Part + " not found in message " + hb.Message);
611 if (hb.Use == SoapBindingUse.Literal)
613 map = xmlImporter.ImportDerivedTypeMapping (part.Element, typeof (SoapHeader));
614 xmlExporter.ExportTypeMapping (map);
618 map = soapImporter.ImportDerivedTypeMapping (part.Type, typeof (SoapHeader), true);
619 soapExporter.ExportTypeMapping (map);
622 bool required = false;
624 string varName = headerVariables [map] as string;
627 varName = memberIds.AddUnique(CodeIdentifier.MakeValid (map.TypeName + "Value"),hb);
628 headerVariables.Add (map, varName);
629 CodeMemberField codeField = new CodeMemberField (map.TypeFullName, varName);
630 codeField.Attributes = MemberAttributes.Public;
631 CodeTypeDeclaration.Members.Add (codeField);
634 CodeAttributeDeclaration att = new CodeAttributeDeclaration ("System.Web.Services.Protocols.SoapHeaderAttribute");
635 att.Arguments.Add (GetArg (varName));
636 att.Arguments.Add (GetArg ("Required", required));
637 if (direction != SoapHeaderDirection.In) att.Arguments.Add (GetEnumArg ("Direction", "System.Web.Services.Protocols.SoapHeaderDirection", direction.ToString ()));
638 AddCustomAttribute (method, att, true);