namespace System.Web.Services.Description {
- internal class SoapProtocolReflector : ProtocolReflector
+ internal abstract class SoapProtocolReflector : ProtocolReflector
{
#region Fields
- internal const string EncodingNamespace = "http://schemas.xmlsoap.org/soap/encoding/";
SoapBinding soapBinding;
#endregion // Fields
#region Properties
- public override string ProtocolName {
- get { return "Soap"; }
- }
+ public abstract SoapExtensionReflector ExtensionReflector { get; }
- #endregion // Properties
+ #endregion
#region Methods
protected override void BeginClass ()
{
- SoapBinding sb = new SoapBinding ();
- sb.Transport = SoapBinding.HttpTransport;
- sb.Style = ((SoapTypeStubInfo)TypeInfo).SoapBindingStyle;
- Binding.Extensions.Add (sb);
-
- SoapAddressBinding abind = new SoapAddressBinding ();
- abind.Location = ServiceUrl;
- Port.Extensions.Add (abind);
+ ExtensionReflector.ReflectDescription ();
}
protected override void EndClass ()
protected override bool ReflectMethod ()
{
- SoapOperationBinding sob = new SoapOperationBinding();
SoapMethodStubInfo method = (SoapMethodStubInfo) MethodStubInfo;
-
- sob.SoapAction = method.Action;
- sob.Style = method.SoapBindingStyle;
- OperationBinding.Extensions.Add (sob);
-
+ bool existing = false;
+ if (Parent != null) {
+ if (Parent.MappedMessagesIn.ContainsKey (method.MethodInfo))
+ existing = true;
+ else {
+ Parent.MappedMessagesIn [method.MethodInfo] = InputMessage;
+ Parent.MappedMessagesOut [method.MethodInfo] = OutputMessage;
+ }
+ }
+ if (!existing)
+ ImportMessageParts ();
+ ExtensionReflector.ReflectMethod ();
+
+ return !existing;
+ }
+
+ void ImportMessageParts ()
+ {
+ SoapMethodStubInfo method = (SoapMethodStubInfo) MethodStubInfo;
ImportMessage (method.InputMembersMapping, InputMessage);
ImportMessage (method.OutputMembersMapping, OutputMessage);
- AddOperationMsgBindings (method, OperationBinding.Input);
- AddOperationMsgBindings (method, OperationBinding.Output);
- foreach (HeaderInfo hf in method.Headers)
+ foreach (SoapHeaderMapping hf in method.Headers)
{
- if (hf.IsUnknownHeader) continue;
+ if (hf.Custom) continue;
Message msg = new Message ();
msg.Name = Operation.Name + hf.HeaderType.Name;
msg.Parts.Add (part);
ServiceDescription.Messages.Add (msg);
- SoapHeaderBinding hb = new SoapHeaderBinding ();
- hb.Message = new XmlQualifiedName (msg.Name, ServiceDescription.TargetNamespace);
- hb.Part = part.Name;
- hb.Use = method.Use;
-
if (method.Use == SoapBindingUse.Literal)
{
// MS.NET reflects header classes in a weird way. The root element
XmlTypeMapping mapping = SoapReflectionImporter.ImportTypeMapping (hf.HeaderType, TypeInfo.LogicalType.GetWebServiceEncodedNamespace (ServiceDescription.TargetNamespace));
part.Type = new XmlQualifiedName (mapping.ElementName, mapping.Namespace);
SoapSchemaExporter.ExportTypeMapping (mapping);
- hb.Encoding = EncodingNamespace;
}
-
- if ((hf.Direction & SoapHeaderDirection.Out) != 0)
- OperationBinding.Output.Extensions.Add (hb);
- if ((hf.Direction & SoapHeaderDirection.In) != 0)
- OperationBinding.Input.Extensions.Add (hb);
- }
-
- return true;
- }
-
- void AddOperationMsgBindings (SoapMethodStubInfo method, MessageBinding msg)
- {
- SoapBodyBinding sbbo = new SoapBodyBinding();
- msg.Extensions.Add (sbbo);
- sbbo.Use = method.Use;
- if (method.Use == SoapBindingUse.Encoded)
- {
- sbbo.Namespace = ServiceDescription.TargetNamespace;
- sbbo.Encoding = EncodingNamespace;
}
}
#endregion
}
+
+ internal class Soap11ProtocolReflector : SoapProtocolReflector
+ {
+ SoapExtensionReflector reflector;
+
+ public Soap11ProtocolReflector ()
+ {
+ reflector = new Soap11BindingExtensionReflector ();
+ reflector.ReflectionContext = this;
+ }
+
+ public override string ProtocolName {
+ get { return "Soap"; }
+ }
+
+ public override SoapExtensionReflector ExtensionReflector {
+ get { return reflector; }
+ }
+ }
+
+ internal class Soap12ProtocolReflector : SoapProtocolReflector
+ {
+ SoapExtensionReflector reflector;
+
+ public Soap12ProtocolReflector ()
+ {
+ reflector = new Soap12BindingExtensionReflector ();
+ reflector.ReflectionContext = this;
+ }
+
+ public override string ProtocolName {
+ get { return "Soap12"; }
+ }
+
+ public override SoapExtensionReflector ExtensionReflector {
+ get { return reflector; }
+ }
+ }
}