private void CreateEncodedMessage(Message message, MessageBinding messageBinding, XmlMembersMapping members, bool wrapped) { this.SoapExporter.ExportMembersMapping(members, wrapped); if (wrapped) { MessagePart messagePart = new MessagePart { Name = "parameters", Type = new XmlQualifiedName(members.TypeName, members.TypeNamespace) }; message.Parts.Add(messagePart); } else { for (int i = 0; i < members.Count; i++) { XmlMemberMapping mapping = members[i]; MessagePart part2 = new MessagePart { Name = mapping.XsdElementName, Type = new XmlQualifiedName(mapping.TypeName, mapping.TypeNamespace) }; message.Parts.Add(part2); } } messageBinding.Extensions.Add(this.CreateSoapBodyBinding(SoapBindingUse.Encoded, members.Namespace)); }
void CreateEncodedMessage(Message message, MessageBinding messageBinding, XmlMembersMapping members, bool wrapped) { SoapExporter.ExportMembersMapping(members, wrapped); if (wrapped) { MessagePart part = new MessagePart(); part.Name = "parameters"; part.Type = new XmlQualifiedName(members.TypeName, members.TypeNamespace); message.Parts.Add(part); } else { for (int i = 0; i < members.Count; i++) { XmlMemberMapping member = members[i]; MessagePart part = new MessagePart(); part.Name = member.ElementName; part.Type = new XmlQualifiedName(member.TypeName, member.TypeNamespace); message.Parts.Add(part); } } messageBinding.Extensions.Add(CreateSoapBodyBinding(SoapBindingUse.Encoded, members.Namespace)); }
SoapBindingUse GetMessageEncoding(MessageBinding mb) { SoapBodyBinding sbb = mb.Extensions.Find(typeof(SoapBodyBinding)) as SoapBodyBinding; if (sbb == null) { if (mb is InputBinding) { return(SoapBindingUse.Encoded); } else { return(SoapBindingUse.Literal); } } else if (sbb.Use == SoapBindingUse.Encoded) { return(SoapBindingUse.Encoded); } else { return(SoapBindingUse.Literal); } }
void CreateLiteralMessage(Message message, MessageBinding messageBinding, XmlMembersMapping members, bool wrapped) { if (members.Count == 1 && members[0].Any && members[0].ElementName.Length == 0 && !wrapped) { string typeName = SchemaExporter.ExportAnyType(members[0].Namespace); MessagePart part = new MessagePart(); part.Name = members[0].MemberName; part.Type = new XmlQualifiedName(typeName, members[0].Namespace); message.Parts.Add(part); } else { SchemaExporter.ExportMembersMapping(members); if (wrapped) { MessagePart part = new MessagePart(); part.Name = "parameters"; part.Element = new XmlQualifiedName(members.ElementName, members.Namespace); message.Parts.Add(part); } else { for (int i = 0; i < members.Count; i++) { XmlMemberMapping member = members[i]; MessagePart part = new MessagePart(); part.Name = member.MemberName; part.Element = new XmlQualifiedName(member.ElementName, member.Namespace); message.Parts.Add(part); } } } messageBinding.Extensions.Add(CreateSoapBodyBinding(SoapBindingUse.Literal, null)); }
private static string GetPolicyReferences(System.Web.Services.Description.MessageBinding binding) { if (binding != null) { var extensions = binding.Extensions; if (extensions.Count > 0) { XmlElement extensionElement = extensions[0] as XmlElement; if (extensionElement != null) { if (extensionElement.LocalName == "PolicyReference" && extensionElement.NamespaceURI == "http://schemas.xmlsoap.org/ws/2004/09/policy") { XmlAttribute uri = extensionElement.Attributes["URI"]; if (uri != null) { string uriValue = uri.Value; if (uriValue.StartsWith("#")) { return(uriValue.Substring(1)); } } } } } } return(null); }
void AddOperationMsgBindings(SoapMethodStubInfo method, MessageBinding msg) { SoapBodyBinding sbbo = CreateSoapBodyBinding(); msg.Extensions.Add(sbbo); sbbo.Use = method.Use; if (method.Use == SoapBindingUse.Encoded) { sbbo.Namespace = ReflectionContext.ServiceDescription.TargetNamespace; sbbo.Encoding = EncodingNS; } }
static void TestSoapMessage(WS.MessageBinding binding, bool soap12, TestLabel label) { label.EnterScope(binding is WS.InputBinding ? "input" : "output"); Assert.That(binding, Is.Not.Null, label.Get()); Assert.That(binding.Name, Is.Null, label.Get()); Assert.That(binding.ExtensibleAttributes, Is.Null, label.Get()); Assert.That(binding.Extensions, Is.Not.Null, label.Get()); Assert.That(binding.Extensions.Count, Is.EqualTo(1), label.Get()); Assert.That(binding.Extensions [0], Is.InstanceOfType(typeof(WS.SoapBodyBinding)), label.Get()); var body = (WS.SoapBodyBinding)binding.Extensions [0]; TestSoapBody(body, soap12, label); label.LeaveScope(); }
private void CreateLiteralMessage(Message message, MessageBinding messageBinding, XmlMembersMapping members, bool wrapped, bool rpc) { if (((members.Count == 1) && members[0].Any) && ((members[0].ElementName.Length == 0) && !wrapped)) { string name = base.SchemaExporter.ExportAnyType(members[0].Namespace); MessagePart messagePart = new MessagePart { Name = members[0].MemberName, Type = new XmlQualifiedName(name, members[0].Namespace) }; message.Parts.Add(messagePart); } else { base.SchemaExporter.ExportMembersMapping(members, !rpc); if (wrapped) { MessagePart part2 = new MessagePart { Name = "parameters", Element = new XmlQualifiedName(members.XsdElementName, members.Namespace) }; message.Parts.Add(part2); } else { for (int i = 0; i < members.Count; i++) { XmlMemberMapping mapping = members[i]; MessagePart part3 = new MessagePart(); if (rpc) { if ((mapping.TypeName == null) || (mapping.TypeName.Length == 0)) { throw new InvalidOperationException(System.Web.Services.Res.GetString("WsdlGenRpcLitAnonimousType", new object[] { base.Method.DeclaringType.Name, base.Method.Name, mapping.MemberName })); } part3.Name = mapping.XsdElementName; part3.Type = new XmlQualifiedName(mapping.TypeName, mapping.TypeNamespace); } else { part3.Name = XmlConvert.EncodeLocalName(mapping.MemberName); part3.Element = new XmlQualifiedName(mapping.XsdElementName, mapping.Namespace); } message.Parts.Add(part3); } } } messageBinding.Extensions.Add(this.CreateSoapBodyBinding(SoapBindingUse.Literal, rpc ? members.Namespace : null)); }
void CreateLiteralMessage(Message message, MessageBinding messageBinding, XmlMembersMapping members, bool wrapped, bool rpc) { if (members.Count == 1 && members[0].Any && members[0].ElementName.Length == 0 && !wrapped) { string typeName = SchemaExporter.ExportAnyType(members[0].Namespace); MessagePart part = new MessagePart(); part.Name = members[0].MemberName; part.Type = new XmlQualifiedName(typeName, members[0].Namespace); message.Parts.Add(part); } else { SchemaExporter.ExportMembersMapping(members, !rpc); if (wrapped) { MessagePart part = new MessagePart(); part.Name = "parameters"; part.Element = new XmlQualifiedName(members.XsdElementName, members.Namespace); message.Parts.Add(part); } else { for (int i = 0; i < members.Count; i++) { XmlMemberMapping member = members[i]; MessagePart part = new MessagePart(); if (rpc) { // Generate massage part with the type attribute if (member.TypeName == null || member.TypeName.Length == 0) { throw new InvalidOperationException(Res.GetString(Res.WsdlGenRpcLitAnonimousType, Method.DeclaringType.Name, Method.Name, member.MemberName)); } part.Name = member.XsdElementName; part.Type = new XmlQualifiedName(member.TypeName, member.TypeNamespace); } else { part.Name = XmlConvert.EncodeLocalName(member.MemberName); part.Element = new XmlQualifiedName(member.XsdElementName, member.Namespace); } message.Parts.Add(part); } } } messageBinding.Extensions.Add(CreateSoapBodyBinding(SoapBindingUse.Literal, rpc ? members.Namespace : null)); }
bool HasHeader(MessageBinding msg, SoapHeaderBinding hb) { if (msg == null) { return(false); } foreach (object ob in msg.Extensions) { SoapHeaderBinding mhb = ob as SoapHeaderBinding; if ((mhb != null) && (mhb.Message == hb.Message) && (mhb.Part == hb.Part)) { return(true); } } return(false); }
static WsdlNS.SoapBodyBinding CreateSoapBodyBinding(EnvelopeVersion version, WsdlNS.MessageBinding wsdlMessageBinding) { WsdlNS.SoapBodyBinding soapBodyBinding = null; if (version == EnvelopeVersion.Soap12) { soapBodyBinding = new WsdlNS.Soap12BodyBinding(); } else if (version == EnvelopeVersion.Soap11) { soapBodyBinding = new WsdlNS.SoapBodyBinding(); } Fx.Assert(soapBodyBinding != null, "EnvelopeVersion is not recognized. Please update the SoapHelper class"); wsdlMessageBinding.Extensions.Add(soapBodyBinding); return(soapBodyBinding); }
internal static bool Check(SoapHeaderBinding soapHeaderBinding, MessageBinding messageBinding, WsdlWarningHandler warningHandler) { if ((soapHeaderBinding.Message == null) || soapHeaderBinding.Message.IsEmpty) { string str = System.ServiceModel.SR.GetString("XsdMissingRequiredAttribute1", new object[] { "message" }); string warning = System.ServiceModel.SR.GetString("IgnoreSoapHeaderBinding3", new object[] { messageBinding.OperationBinding.Name, messageBinding.OperationBinding.Binding.ServiceDescription.TargetNamespace, str }); warningHandler(warning); return false; } if (string.IsNullOrEmpty(soapHeaderBinding.Part)) { string str3 = System.ServiceModel.SR.GetString("XsdMissingRequiredAttribute1", new object[] { "part" }); string str4 = System.ServiceModel.SR.GetString("IgnoreSoapHeaderBinding3", new object[] { messageBinding.OperationBinding.Name, messageBinding.OperationBinding.Binding.ServiceDescription.TargetNamespace, str3 }); warningHandler(str4); return false; } return true; }
void AddMessageSchema(XmlSchemas schemas, MessageBinding mb, Message msg) { foreach (MessagePart part in msg.Parts) { if (part.Element != XmlQualifiedName.Empty) { AddIncludingSchema(schemas, part.Element.Namespace); } else if (part.Type != XmlQualifiedName.Empty) { AddIncludingSchema(schemas, part.Type.Namespace); } } SoapBodyBinding sbb = mb.Extensions.Find(typeof(SoapBodyBinding)) as SoapBodyBinding; if (sbb != null) { AddIncludingSchema(schemas, sbb.Namespace); } }
Message FindMessage(ConformanceCheckContext ctx, MessageBinding mb) { PortType pt = ctx.Services.GetPortType(mb.OperationBinding.Binding.Type); foreach (Operation op in pt.Operations) { if (op.IsBoundBy(mb.OperationBinding)) { OperationMessage om; if (mb is InputBinding) { om = op.Messages.Input; } else if (mb is OutputBinding) { om = op.Messages.Output; } else if (mb is FaultBinding) { om = op.Faults [mb.Name]; } else { return(null); } if (om != null) { return(ctx.Services.GetMessage(om.Message)); } else { return(null); } } } return(null); }
bool HasHeader (MessageBinding msg, SoapHeaderBinding hb) { if (msg == null) return false; foreach (object ob in msg.Extensions) { SoapHeaderBinding mhb = ob as SoapHeaderBinding; if ((mhb != null) && (mhb.Message == hb.Message) && (mhb.Part == hb.Part)) return true; } return false; }
private void CreateMessage(bool rpc, SoapBindingUse use, SoapParameterStyle paramStyle, Message message, MessageBinding messageBinding, XmlMembersMapping members) { bool flag = paramStyle != SoapParameterStyle.Bare; if (use == SoapBindingUse.Encoded) { this.CreateEncodedMessage(message, messageBinding, members, flag && !rpc); } else { this.CreateLiteralMessage(message, messageBinding, members, flag && !rpc, rpc); } }
internal static WsdlNS.SoapBodyBinding GetOrCreateSoapBodyBinding(WsdlEndpointConversionContext endpointContext, WsdlNS.MessageBinding wsdlMessageBinding, WsdlExporter exporter) { if (GetSoapVersionState(endpointContext.WsdlBinding, exporter) == EnvelopeVersion.None) { return(null); } WsdlNS.SoapBodyBinding existingSoapBodyBinding = GetSoapBodyBinding(endpointContext, wsdlMessageBinding); EnvelopeVersion version = GetSoapVersion(endpointContext.WsdlBinding); if (existingSoapBodyBinding != null) { return(existingSoapBodyBinding); } WsdlNS.SoapBodyBinding soapBodyBinding = CreateSoapBodyBinding(version, wsdlMessageBinding); return(soapBodyBinding); }
void GenerateHeaders(CodeAttributeDeclarationCollection metadata, SoapBindingUse use, bool rpc, MessageBinding requestMessage, MessageBinding responseMessage) { Hashtable localHeaders = new Hashtable(); for (int i = 0; i < 2; ++i) { MessageBinding messageBinding; SoapHeaderDirection direction; if (i == 0) { messageBinding = requestMessage; direction = SoapHeaderDirection.In; } else if (responseMessage != null) { messageBinding = responseMessage; direction = SoapHeaderDirection.Out; } else continue; SoapHeaderBinding[] headerBindings = (SoapHeaderBinding[])messageBinding.Extensions.FindAll(typeof(SoapHeaderBinding)); foreach (SoapHeaderBinding header in headerBindings) { // Skip headers which should not be mapped to properties (extension importers can control this) if (!header.MapToProperty) continue; if (use != header.Use) throw new InvalidOperationException(Res.GetString(Res.WebDescriptionHeaderAndBodyUseMismatch)); if (use == SoapBindingUse.Encoded && !IsSoapEncodingPresent(header.Encoding) ) throw new InvalidOperationException(Res.GetString(Res.WebUnknownEncodingStyle, header.Encoding)); Message message = ServiceDescriptions.GetMessage(header.Message); if (message == null) throw new InvalidOperationException(Res.GetString(Res.MissingMessage2, header.Message.Name, header.Message.Namespace)); MessagePart part = message.FindPartByName(header.Part); if (part == null) throw new InvalidOperationException(Res.GetString(Res.MissingMessagePartForMessageFromNamespace3, part.Name, header.Message.Name, header.Message.Namespace)); XmlTypeMapping mapping; string key; if (use == SoapBindingUse.Encoded) { if (part.Type.IsEmpty) throw new InvalidOperationException(Res.GetString(Res.WebDescriptionPartTypeRequired, part.Name, header.Message.Name, header.Message.Namespace)); if (!part.Element.IsEmpty) UnsupportedOperationBindingWarning(Res.GetString(Res.WebDescriptionPartElementWarning, part.Name, header.Message.Name, header.Message.Namespace)); mapping = soapImporter.ImportDerivedTypeMapping(part.Type, typeof(SoapHeader), true); key = "type=" + part.Type.ToString(); } else { if (part.Element.IsEmpty) throw new InvalidOperationException(Res.GetString(Res.WebDescriptionPartElementRequired, part.Name, header.Message.Name, header.Message.Namespace)); if (!part.Type.IsEmpty) UnsupportedOperationBindingWarning(Res.GetString(Res.WebDescriptionPartTypeWarning, part.Name, header.Message.Name, header.Message.Namespace)); mapping = xmlImporter.ImportDerivedTypeMapping(part.Element, typeof(SoapHeader), true); key = "element=" + part.Element.ToString(); } LocalSoapHeader localHeader = (LocalSoapHeader)localHeaders[key]; if (localHeader == null) { GlobalSoapHeader globalHeader = (GlobalSoapHeader)classHeaders[key]; if (globalHeader == null) { globalHeader = new GlobalSoapHeader(); globalHeader.isEncoded = use == SoapBindingUse.Encoded; string fieldName = CodeIdentifier.MakeValid(mapping.ElementName); if (fieldName == mapping.TypeName) fieldName += "Value"; fieldName = MethodNames.AddUnique(fieldName, mapping); globalHeader.fieldName = fieldName; WebCodeGenerator.AddMember(CodeTypeDeclaration, mapping.TypeFullName, globalHeader.fieldName, null, null, CodeFlags.IsPublic, ServiceImporter.CodeGenerationOptions); globalHeader.mapping = mapping; classHeaders.Add(key, globalHeader); if (headers[key] == null) headers.Add(key, globalHeader); } localHeader = new LocalSoapHeader(); localHeader.fieldName = globalHeader.fieldName; localHeader.direction = direction; localHeaders.Add(key, localHeader); } else { if (localHeader.direction != direction) localHeader.direction = SoapHeaderDirection.InOut; } } } foreach (LocalSoapHeader soapHeader in localHeaders.Values) { BeginMetadata(); if (soapHeader.direction == SoapHeaderDirection.Out) { AddMetadataProperty("Direction", new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(typeof(SoapHeaderDirection).FullName), SoapHeaderDirection.Out.ToString())); } else if (soapHeader.direction == SoapHeaderDirection.InOut) { AddMetadataProperty("Direction", new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(typeof(SoapHeaderDirection).FullName), SoapHeaderDirection.InOut.ToString())); } EndMetadata(metadata, typeof(SoapHeaderAttribute), soapHeader.fieldName); } }
/// <summary> /// Exports the message header binding. /// </summary> /// <param name="info">The info.</param> /// <param name="messageBinding">The message binding.</param> /// <param name="qsName">Name of the qs.</param> /// <param name="isEncoded">if set to <c>true</c> [is encoded].</param> private void ExportMessageHeaderBinding(CustomHeaderExportInfo info, MessageBinding messageBinding, XmlQualifiedName qsName) { ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "ExportMessageHeaderBinding"); try { SoapHeaderBinding binding = new SoapHeaderBinding(); binding.Part = info.PartName; binding.Message = qsName; binding.Use = (info.IsEncoded ? SoapBindingUse.Encoded : SoapBindingUse.Literal); messageBinding.Extensions.Add(binding); } catch (Exception ex) { Log.Exception(PROC, ex); } }
internal void AddMessageBinding(MessageDescription messageDescription, MessageBinding wsdlMessageBinding) { this.wsdlMessageBindings.Add(messageDescription, wsdlMessageBinding); this.messageDescriptionBindings.Add(wsdlMessageBinding, messageDescription); }
public MessageDescription GetMessageDescription(WsdlNS.MessageBinding messageBinding) { return(_messageDescriptionBindings[messageBinding]); }
void CheckMessageBinding (ConformanceCheckContext ctx, Hashtable portParts, MessageBinding value) { SoapBodyBinding sbb = (SoapBodyBinding) value.Extensions.Find (typeof(SoapBodyBinding)); Message msg = FindMessage (ctx, value); LiteralType bt = GetLiteralBindingType (value.OperationBinding.Binding); if (sbb != null) { if (bt == LiteralType.Document) { if (sbb.Parts != null && sbb.Parts.Length > 1) ctx.ReportRuleViolation (value, BasicProfileRules.R2201); if (sbb.Parts == null) { if (msg.Parts != null && msg.Parts.Count > 1) ctx.ReportRuleViolation (value, BasicProfileRules.R2210); if (msg.Parts.Count == 1) portParts.Remove (msg.Parts[0]); } else { if (sbb.Parts.Length == 0 && msg.Parts.Count == 1) { portParts.Remove (msg.Parts[0]); } else { foreach (string part in sbb.Parts) { MessagePart mp = msg.FindPartByName (part); portParts.Remove (mp); if (!mp.DefinedByElement) ctx.ReportRuleViolation (value, BasicProfileRules.R2204); } } } } else if (bt == LiteralType.Rpc) { if (sbb.Parts != null) { foreach (string part in sbb.Parts) { MessagePart mp = msg.FindPartByName (part); portParts.Remove (mp); if (!mp.DefinedByType) ctx.ReportRuleViolation (value, BasicProfileRules.R2203); } } } } SoapHeaderBinding shb = (SoapHeaderBinding) value.Extensions.Find (typeof(SoapHeaderBinding)); if (shb != null) { Message hm = ctx.Services.GetMessage (shb.Message); MessagePart mp = hm.FindPartByName (shb.Part); portParts.Remove (mp); if (mp != null && !mp.DefinedByElement) ctx.ReportRuleViolation (value, BasicProfileRules.R2205); } SoapHeaderFaultBinding shfb = (SoapHeaderFaultBinding) value.Extensions.Find (typeof(SoapHeaderFaultBinding)); if (shfb != null) { Message hm = ctx.Services.GetMessage (shfb.Message); MessagePart mp = hm.FindPartByName (shfb.Part); portParts.Remove (mp); if (mp != null && !mp.DefinedByElement) ctx.ReportRuleViolation (value, BasicProfileRules.R2205); } // TODO: SoapFaultBinding ?? }
static void ImportMessageSoapAction(WsdlContractConversionContext contractContext, MessageDescription message, MessageBinding wsdlMessageBinding, bool isResponse) { string soapAction = SoapHelper.ReadSoapAction(wsdlMessageBinding.OperationBinding); if (contractContext != null) { OperationMessage wsdlOperationMessage = contractContext.GetOperationMessage(message); string wsaAction = WsdlImporter.WSAddressingHelper.FindWsaActionAttribute(wsdlOperationMessage); if (wsaAction == null && soapAction != null) { if (isResponse) { message.Action = "*"; } else { message.Action = soapAction; } } // } else { // } }
public virtual void Check (ConformanceCheckContext ctx, MessageBinding value) { }
private void PrepareHeaders(MessageBinding messageBinding) { SoapHeaderBinding[] bindingArray = (SoapHeaderBinding[]) messageBinding.Extensions.FindAll(typeof(SoapHeaderBinding)); foreach (SoapHeaderBinding binding in bindingArray) { binding.MapToProperty = true; } }
private void GenerateHeaders(CodeAttributeDeclarationCollection metadata, SoapBindingUse use, bool rpc, MessageBinding requestMessage, MessageBinding responseMessage) { Hashtable hashtable = new Hashtable(); for (int i = 0; i < 2; i++) { MessageBinding binding; SoapHeaderDirection @in; if (i == 0) { binding = requestMessage; @in = SoapHeaderDirection.In; } else { if (responseMessage == null) { continue; } binding = responseMessage; @in = SoapHeaderDirection.Out; } SoapHeaderBinding[] bindingArray = (SoapHeaderBinding[]) binding.Extensions.FindAll(typeof(SoapHeaderBinding)); foreach (SoapHeaderBinding binding2 in bindingArray) { if (binding2.MapToProperty) { XmlTypeMapping mapping; string str; if (use != binding2.Use) { throw new InvalidOperationException(System.Web.Services.Res.GetString("WebDescriptionHeaderAndBodyUseMismatch")); } if ((use == SoapBindingUse.Encoded) && !this.IsSoapEncodingPresent(binding2.Encoding)) { throw new InvalidOperationException(System.Web.Services.Res.GetString("WebUnknownEncodingStyle", new object[] { binding2.Encoding })); } Message message = base.ServiceDescriptions.GetMessage(binding2.Message); if (message == null) { throw new InvalidOperationException(System.Web.Services.Res.GetString("MissingMessage2", new object[] { binding2.Message.Name, binding2.Message.Namespace })); } MessagePart part = message.FindPartByName(binding2.Part); if (part == null) { throw new InvalidOperationException(System.Web.Services.Res.GetString("MissingMessagePartForMessageFromNamespace3", new object[] { part.Name, binding2.Message.Name, binding2.Message.Namespace })); } if (use == SoapBindingUse.Encoded) { if (part.Type.IsEmpty) { throw new InvalidOperationException(System.Web.Services.Res.GetString("WebDescriptionPartTypeRequired", new object[] { part.Name, binding2.Message.Name, binding2.Message.Namespace })); } if (!part.Element.IsEmpty) { base.UnsupportedOperationBindingWarning(System.Web.Services.Res.GetString("WebDescriptionPartElementWarning", new object[] { part.Name, binding2.Message.Name, binding2.Message.Namespace })); } mapping = this.soapImporter.ImportDerivedTypeMapping(part.Type, typeof(SoapHeader), true); str = "type=" + part.Type.ToString(); } else { if (part.Element.IsEmpty) { throw new InvalidOperationException(System.Web.Services.Res.GetString("WebDescriptionPartElementRequired", new object[] { part.Name, binding2.Message.Name, binding2.Message.Namespace })); } if (!part.Type.IsEmpty) { base.UnsupportedOperationBindingWarning(System.Web.Services.Res.GetString("WebDescriptionPartTypeWarning", new object[] { part.Name, binding2.Message.Name, binding2.Message.Namespace })); } mapping = this.xmlImporter.ImportDerivedTypeMapping(part.Element, typeof(SoapHeader), true); str = "element=" + part.Element.ToString(); } LocalSoapHeader header = (LocalSoapHeader) hashtable[str]; if (header == null) { GlobalSoapHeader header2 = (GlobalSoapHeader) this.classHeaders[str]; if (header2 == null) { header2 = new GlobalSoapHeader { isEncoded = use == SoapBindingUse.Encoded }; string identifier = CodeIdentifier.MakeValid(mapping.ElementName); if (identifier == mapping.TypeName) { identifier = identifier + "Value"; } identifier = base.MethodNames.AddUnique(identifier, mapping); header2.fieldName = identifier; WebCodeGenerator.AddMember(base.CodeTypeDeclaration, mapping.TypeFullName, header2.fieldName, null, null, CodeFlags.IsPublic, base.ServiceImporter.CodeGenerationOptions); header2.mapping = mapping; this.classHeaders.Add(str, header2); if (this.headers[str] == null) { this.headers.Add(str, header2); } } header = new LocalSoapHeader { fieldName = header2.fieldName, direction = @in }; hashtable.Add(str, header); } else if (header.direction != @in) { header.direction = SoapHeaderDirection.InOut; } } } } foreach (LocalSoapHeader header3 in hashtable.Values) { this.BeginMetadata(); if (header3.direction == SoapHeaderDirection.Out) { this.AddMetadataProperty("Direction", (CodeExpression) new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(typeof(SoapHeaderDirection).FullName), SoapHeaderDirection.Out.ToString())); } else if (header3.direction == SoapHeaderDirection.InOut) { this.AddMetadataProperty("Direction", (CodeExpression) new CodeFieldReferenceExpression(new CodeTypeReferenceExpression(typeof(SoapHeaderDirection).FullName), SoapHeaderDirection.InOut.ToString())); } this.EndMetadata(metadata, typeof(SoapHeaderAttribute), header3.fieldName); } }
void AddOperationMsgBindings (SoapMethodStubInfo method, MessageBinding msg) { SoapBodyBinding sbbo = CreateSoapBodyBinding (); msg.Extensions.Add (sbbo); sbbo.Use = method.Use; if (method.Use == SoapBindingUse.Encoded) { sbbo.Namespace = ReflectionContext.ServiceDescription.TargetNamespace; sbbo.Encoding = EncodingNS; } }
SoapBindingUse GetMessageEncoding (MessageBinding mb) { SoapBodyBinding sbb = mb.Extensions.Find (typeof(SoapBodyBinding)) as SoapBodyBinding; if (sbb == null) { if (mb is InputBinding) return SoapBindingUse.Encoded; else return SoapBindingUse.Literal; } else if (sbb.Use == SoapBindingUse.Encoded) return SoapBindingUse.Encoded; else return SoapBindingUse.Literal; }
void AddMessageSchema (XmlSchemas schemas, MessageBinding mb, Message msg) { foreach (MessagePart part in msg.Parts) { if (part.Element != XmlQualifiedName.Empty) AddIncludingSchema (schemas, part.Element.Namespace); else if (part.Type != XmlQualifiedName.Empty) AddIncludingSchema (schemas, part.Type.Namespace); } SoapBodyBinding sbb = mb.Extensions.Find (typeof(SoapBodyBinding)) as SoapBodyBinding; if (sbb != null) AddIncludingSchema (schemas, sbb.Namespace); }
Message FindMessage (ConformanceCheckContext ctx, MessageBinding mb) { PortType pt = ctx.Services.GetPortType (mb.OperationBinding.Binding.Type); foreach (Operation op in pt.Operations) if (op.IsBoundBy (mb.OperationBinding)) { OperationMessage om; if (mb is InputBinding) om = op.Messages.Input; else if (mb is OutputBinding) om = op.Messages.Output; else if (mb is FaultBinding) om = op.Messages.Fault; else return null; return ctx.Services.GetMessage (om.Message); } return null; }
private void ExportMessageBodyBinding(MessageDescription messageDescription, bool isRpc, bool isEncoded, MessageBinding messageBinding) { SoapBodyBinding binding = SoapHelper.GetOrCreateSoapBodyBinding(this.endpointContext, messageBinding, this.exporter); if (binding != null) { binding.Use = isEncoded ? SoapBindingUse.Encoded : SoapBindingUse.Literal; if (isRpc) { string wrapperNamespace; if (!this.ExportedMessages.WrapperNamespaces.TryGetValue(new MessageContractExporter.MessageDescriptionDictionaryKey(this.endpointContext.ContractConversionContext.Contract, messageDescription), out wrapperNamespace)) { wrapperNamespace = messageDescription.Body.WrapperNamespace; } binding.Namespace = wrapperNamespace; } if (isEncoded) { binding.Encoding = XmlSerializerOperationFormatter.GetEncoding(this.soapVersion); } } }
internal void AddMessageBinding(MessageDescription messageDescription, WsdlNS.MessageBinding wsdlMessageBinding) { _wsdlMessageBindings.Add(messageDescription, wsdlMessageBinding); _messageDescriptionBindings.Add(wsdlMessageBinding, messageDescription); }
void PrepareHeaders(MessageBinding messageBinding) { // By default, map all headers to properties on the generated class // ExtensionImporters can modify this behavior by clearing the flag SoapHeaderBinding[] headers = (SoapHeaderBinding[])messageBinding.Extensions.FindAll(typeof(SoapHeaderBinding)); foreach (SoapHeaderBinding header in headers) { header.MapToProperty = true; } }
public MessageDescription GetMessageDescription(MessageBinding messageBinding) { return this.messageDescriptionBindings[messageBinding]; }
private static void ImportMessageSoapAction(WsdlContractConversionContext contractContext, MessageDescription message, MessageBinding wsdlMessageBinding, bool isResponse) { string str = SoapHelper.ReadSoapAction(wsdlMessageBinding.OperationBinding); if (((contractContext != null) && (WsdlImporter.WSAddressingHelper.FindWsaActionAttribute(contractContext.GetOperationMessage(message)) == null)) && (str != null)) { if (isResponse) { message.Action = "*"; } else { message.Action = str; } } }
public MessageDescription GetMessageDescription ( MessageBinding message) { throw new NotImplementedException (); }
private void HandleHeaders(ServiceDescription wsdl, BindingOperationType op2, ItemsChoiceType1 type, MessageBinding mb, SoapVersion v) { if (op2.Items == null) { return; } for (int i = 0; i < op2.Items.Length; i++) { var curr = op2.Items[i] as BindingOperationMessageType; if (curr == null) { continue; } if (op2.ItemsElementName[i] != type) { continue; } if (curr.Items == null) { continue; } var headers = curr.Items.Where(s => s.LocalName == "header" && s.NamespaceURI == "http://www.w3.org/ns/wsdl/soap"); foreach (var n in headers) { var header = v == SoapVersion.Soap11 ? new SoapHeaderBinding() : new Soap12HeaderBinding(); header.Use = SoapBindingUse.Literal; if (n.Attributes["element"] == null) { return; } var qName = new XmlQualifiedName(n.Attributes["element"].Value); const string partName = "H"; header.Message = CreateMessage(wsdl, String.Format("{0}Header_{1}", [email protected], unique++), qName, partName); header.Part = partName; mb.Extensions.Add(header); } } }
internal static WsdlNS.SoapHeaderBinding CreateSoapHeaderBinding(WsdlEndpointConversionContext endpointContext, WsdlNS.MessageBinding wsdlMessageBinding) { EnvelopeVersion version = GetSoapVersion(endpointContext.WsdlBinding); WsdlNS.SoapHeaderBinding soapHeaderBinding = CreateSoapHeaderBinding(version, wsdlMessageBinding); return(soapHeaderBinding); }
static WsdlNS.SoapBodyBinding GetSoapBodyBinding(WsdlEndpointConversionContext endpointContext, WsdlNS.MessageBinding wsdlMessageBinding) { foreach (object o in wsdlMessageBinding.Extensions) { if (o is WsdlNS.SoapBodyBinding) { return((WsdlNS.SoapBodyBinding)o); } } return(null); }
void CheckMessageBinding(ConformanceCheckContext ctx, Hashtable portParts, MessageBinding value) { SoapBodyBinding sbb = (SoapBodyBinding)value.Extensions.Find(typeof(SoapBodyBinding)); Message msg = FindMessage(ctx, value); LiteralType bt = GetLiteralBindingType(value.OperationBinding.Binding); if (sbb != null) { if (bt == LiteralType.Document) { if (sbb.Parts != null && sbb.Parts.Length > 1) { ctx.ReportRuleViolation(value, BasicProfileRules.R2201); } if (sbb.Parts == null) { if (msg.Parts != null && msg.Parts.Count > 1) { ctx.ReportRuleViolation(value, BasicProfileRules.R2210); } if (msg.Parts.Count == 1) { portParts.Remove(msg.Parts[0]); } } else { if (sbb.Parts.Length == 0 && msg.Parts.Count == 1) { portParts.Remove(msg.Parts[0]); } else { foreach (string part in sbb.Parts) { MessagePart mp = msg.FindPartByName(part); portParts.Remove(mp); if (!mp.DefinedByElement) { ctx.ReportRuleViolation(value, BasicProfileRules.R2204); } } } } } else if (bt == LiteralType.Rpc) { if (sbb.Parts != null) { foreach (string part in sbb.Parts) { MessagePart mp = msg.FindPartByName(part); portParts.Remove(mp); if (!mp.DefinedByType) { ctx.ReportRuleViolation(value, BasicProfileRules.R2203); } } } } } SoapHeaderBinding shb = (SoapHeaderBinding)value.Extensions.Find(typeof(SoapHeaderBinding)); if (shb != null) { Message hm = ctx.Services.GetMessage(shb.Message); MessagePart mp = hm.FindPartByName(shb.Part); portParts.Remove(mp); if (mp != null && !mp.DefinedByElement) { ctx.ReportRuleViolation(value, BasicProfileRules.R2205); } } SoapHeaderFaultBinding shfb = (SoapHeaderFaultBinding)value.Extensions.Find(typeof(SoapHeaderFaultBinding)); if (shfb != null) { Message hm = ctx.Services.GetMessage(shfb.Message); MessagePart mp = hm.FindPartByName(shfb.Part); portParts.Remove(mp); if (mp != null && !mp.DefinedByElement) { ctx.ReportRuleViolation(value, BasicProfileRules.R2205); } } // TODO: SoapFaultBinding ?? }
void CreateMessage(bool rpc, SoapBindingUse use, SoapParameterStyle paramStyle, Message message, MessageBinding messageBinding, XmlMembersMapping members) { bool wrapped = paramStyle != SoapParameterStyle.Bare; if (use == SoapBindingUse.Encoded) CreateEncodedMessage(message, messageBinding, members, wrapped && !rpc); else CreateLiteralMessage(message, messageBinding, members, wrapped && !rpc, rpc); }
private void ExportMessageHeaderBinding(MessageHeaderDescription header, XmlQualifiedName messageName, bool isEncoded, MessageBinding messageBinding) { SoapHeaderBinding binding = SoapHelper.CreateSoapHeaderBinding(this.endpointContext, messageBinding); binding.Part = string.IsNullOrEmpty(header.UniquePartName) ? header.Name : header.UniquePartName; binding.Message = messageName; binding.Use = isEncoded ? SoapBindingUse.Encoded : SoapBindingUse.Literal; if (isEncoded) { binding.Encoding = XmlSerializerOperationFormatter.GetEncoding(this.soapVersion); } }
public virtual void Check(ConformanceCheckContext ctx, MessageBinding value) { }
private void HandleHeaders(ServiceDescription wsdl, BindingOperationType op2, ItemsChoiceType1 type, MessageBinding mb, SoapVersion v) { if (op2.Items == null) return; for (int i = 0; i < op2.Items.Length; i++) { var curr = op2.Items[i] as BindingOperationMessageType; if (curr == null) continue; if (op2.ItemsElementName[i] != type) continue; if (curr.Items == null) continue; var headers = curr.Items.Where(s => s.LocalName == "header" && s.NamespaceURI == "http://www.w3.org/ns/wsdl/soap"); foreach (var n in headers) { var header = v == SoapVersion.Soap11 ? new SoapHeaderBinding() : new Soap12HeaderBinding(); header.Use = SoapBindingUse.Literal; if (n.Attributes["element"] == null) return; var qName = new XmlQualifiedName(n.Attributes["element"].Value); const string partName = "H"; header.Message = CreateMessage(wsdl, String.Format("{0}Header_{1}", [email protected], unique++), qName, partName); header.Part = partName; mb.Extensions.Add(header); } } }
void CreateMessage(bool rpc, SoapBindingUse use, SoapParameterStyle paramStyle, Message message, MessageBinding messageBinding, XmlMembersMapping members) { bool wrapped = paramStyle != SoapParameterStyle.Bare; if (use == SoapBindingUse.Encoded) { CreateEncodedMessage(message, messageBinding, members, wrapped && !rpc); } else { CreateLiteralMessage(message, messageBinding, members, wrapped); } }
private static string CreateMessageBindingPolicyKey(MessageBinding wsdlMessageBinding, MessageDirection direction) { OperationBinding operationBinding = wsdlMessageBinding.OperationBinding; System.Web.Services.Description.Binding binding = operationBinding.Binding; if (direction == MessageDirection.Input) { return string.Format(CultureInfo.InvariantCulture, "{0}_{1}_Input_policy", new object[] { binding.Name, operationBinding.Name }); } return string.Format(CultureInfo.InvariantCulture, "{0}_{1}_output_policy", new object[] { binding.Name, operationBinding.Name }); }